diff --git a/.buildkite/DockerFile b/.buildkite/DockerFile index 227524274d2..9ccd51b4944 100644 --- a/.buildkite/DockerFile +++ b/.buildkite/DockerFile @@ -1,4 +1,4 @@ -ARG DOTNET_VERSION=8.0.400 +ARG DOTNET_VERSION=9.0.100 FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS elasticsearch-net-build ENV NUGET_SCRATCH="/tmp/NuGetScratch" diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 87f461176da..b702d1737b2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,7 @@ steps: env: TEST_SUITE: "{{ matrix.suite }}" STACK_VERSION: master-SNAPSHOT - DOTNET_VERSION: 8.0.400 + DOTNET_VERSION: 9.0.100 matrix: setup: suite: diff --git a/.buildkite/run-repository.ps1 b/.buildkite/run-repository.ps1 index 4a290f1c625..774f3684ccd 100644 --- a/.buildkite/run-repository.ps1 +++ b/.buildkite/run-repository.ps1 @@ -14,7 +14,7 @@ param( $NODE_NAME, [string] - $DOTNET_VERSION = "8.0.400" + $DOTNET_VERSION = "9.0.100" ) $ESC = [char]27 diff --git a/.buildkite/run-repository.sh b/.buildkite/run-repository.sh index 9c212f484c1..d0b1ba84870 100755 --- a/.buildkite/run-repository.sh +++ b/.buildkite/run-repository.sh @@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail -DOTNET_VERSION=${DOTNET_VERSION-8.0.400} +DOTNET_VERSION=${DOTNET_VERSION-9.0.100} ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} elasticsearch_container=${elasticsearch_container-} diff --git a/.buildkite/run-tests.ps1 b/.buildkite/run-tests.ps1 index 503edd8df06..3113065ce2d 100644 --- a/.buildkite/run-tests.ps1 +++ b/.buildkite/run-tests.ps1 @@ -8,7 +8,7 @@ param ( $TEST_SUITE = "free", [string] - $DOTNET_VERSION = "8.0.400" + $DOTNET_VERSION = "9.0.100" ) $ESC = [char]27 diff --git a/.ci/DockerFile b/.ci/DockerFile index 8c642b99967..5ba098c2552 100644 --- a/.ci/DockerFile +++ b/.ci/DockerFile @@ -1,4 +1,4 @@ -ARG DOTNET_VERSION=8.0.400 +ARG DOTNET_VERSION=9.0.100 FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS elasticsearch-net-build ENV NUGET_SCRATCH="/tmp/NuGetScratch" diff --git a/.ci/make.sh b/.ci/make.sh index 672ad78bd7d..ad1dd59e455 100755 --- a/.ci/make.sh +++ b/.ci/make.sh @@ -42,7 +42,7 @@ OUTPUT_DIR="$repo/${output_folder}" REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}" mkdir -p "$OUTPUT_DIR" -DOTNET_VERSION=${DOTNET_VERSION-8.0.400} +DOTNET_VERSION=${DOTNET_VERSION-9.0.100} echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m" echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m" diff --git a/.ci/readme.md b/.ci/readme.md index fe87c60afd4..95bd4f20fc9 100644 --- a/.ci/readme.md +++ b/.ci/readme.md @@ -30,7 +30,7 @@ $ STACK_VERSION=8.0.0-SNAPSHOT ./.ci/run-tests |-------------------------|-------------|-------------| | `STACK_VERSION` | `N/A` | The elasticsearch version to target | `TEST_SUITE` | `basic` | `free` or `platinum` sets which test suite to run and which container to run against. | -| `DOTNET_VERSION` | `8.0.400` | The .NET sdk version used to grab the proper container | +| `DOTNET_VERSION` | `9.0.100` | The .NET sdk version used to grab the proper container | If you want to manually spin up elasticsearch for these tests and call the runner afterwards you can use diff --git a/.ci/run-repository.ps1 b/.ci/run-repository.ps1 index e842f7fe215..877995e542f 100644 --- a/.ci/run-repository.ps1 +++ b/.ci/run-repository.ps1 @@ -14,7 +14,7 @@ param( $NODE_NAME, [string] - $DOTNET_VERSION = "8.0.400" + $DOTNET_VERSION = "9.0.100" ) $ESC = [char]27 diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh index 0e49cdaf1bf..2191e872ea9 100755 --- a/.ci/run-repository.sh +++ b/.ci/run-repository.sh @@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail -DOTNET_VERSION=${DOTNET_VERSION-8.0.400} +DOTNET_VERSION=${DOTNET_VERSION-9.0.100} ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} elasticsearch_container=${elasticsearch_container-} diff --git a/.ci/run-tests.ps1 b/.ci/run-tests.ps1 index 481ad155dbd..89b91ebaadf 100644 --- a/.ci/run-tests.ps1 +++ b/.ci/run-tests.ps1 @@ -8,7 +8,7 @@ param ( $TEST_SUITE = "free", [string] - $DOTNET_VERSION = "8.0.400" + $DOTNET_VERSION = "9.0.100" ) $ESC = [char]27 diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 421f57f8973..0c4a5a2b9ba 100755 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -8,6 +8,6 @@ TEST_SUITE: - platinum DOTNET_VERSION: - - 8.0.400 + - 9.0.100 exclude: ~ diff --git a/Directory.Build.props b/Directory.Build.props index 91ddb2e93ec..cdc634db8d7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -50,4 +50,8 @@ + + + NU1901;NU1902;NU1903;NU1904 + \ No newline at end of file diff --git a/build/scripts/Versioning.fs b/build/scripts/Versioning.fs index 4b27be22871..a3b9d7f2c07 100644 --- a/build/scripts/Versioning.fs +++ b/build/scripts/Versioning.fs @@ -17,7 +17,7 @@ module Versioning = // Since that file is now generated by the dotnet tooling and GitVersion and similar tooling all still have // active issues related to dotnet core, we now just burn this info in global.json - let parse (v:string) = SemVer.parse(v) + let parse (v: string) = SemVer.parse(if String.IsNullOrEmpty(v) then "1.0.0" else v) //Versions in form of e.g 6.1.0 is inferred as datetime so we bake the json shape into the provider like this type SdkVersion = { version:string; rollForward:string; allowPrerelease:bool } diff --git a/build/scripts/scripts.fsproj b/build/scripts/scripts.fsproj index 29ab285f8f5..94f4e3194ff 100644 --- a/build/scripts/scripts.fsproj +++ b/build/scripts/scripts.fsproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Exe $(NoWarn);NU1701 diff --git a/global.json b/global.json index c1ae6f120d3..00b67caef9e 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,7 @@ { "sdk": { - "version": "8.0.400", + "version": "9.0.100", "rollForward": "latestFeature", "allowPrerelease": false - }, - "version": "8.8.0-alpha.1", - "doc_current": "main", - "doc_branch": "main" + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj index d21f64b5921..38e63bfc6b6 100644 --- a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj +++ b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj @@ -16,9 +16,14 @@ true true annotations + true - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs index ed385a30bf7..7cde62d9124 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs @@ -56,6 +56,11 @@ public AsyncSearchStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => { } + [JsonConstructor] + internal AsyncSearchStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.AsyncSearchStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -64,6 +69,14 @@ public AsyncSearchStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override string OperationName => "async_search.status"; + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies how long the async search needs to be available. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs index 126481dc53a..1353e492ef6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs @@ -22,10 +22,161 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusters = default; + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propShards = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propCompletionStatus.TryReadProperty(ref reader, options, PropCompletionStatus, null)) + { + continue; + } + + if (propCompletionTime.TryReadProperty(ref reader, options, PropCompletionTime, null)) + { + continue; + } + + if (propCompletionTimeInMillis.TryReadProperty(ref reader, options, PropCompletionTimeInMillis, null)) + { + continue; + } + + if (propExpirationTime.TryReadProperty(ref reader, options, PropExpirationTime, null)) + { + continue; + } + + if (propExpirationTimeInMillis.TryReadProperty(ref reader, options, PropExpirationTimeInMillis, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propStartTime.TryReadProperty(ref reader, options, PropStartTime, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus, null, null); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime, null, null); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis, null, null); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime, null, null); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropStartTime, value.StartTime, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AsyncSearchStatusResponseConverter))] public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse { /// @@ -34,7 +185,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Not shown for local-only searches. /// /// - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } /// @@ -44,7 +194,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 +202,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 +210,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 +220,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 +228,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 +235,7 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Indicates how many shards have run the query so far. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs index e59001fda74..eef26368123 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs @@ -50,6 +50,11 @@ public DeleteAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => { } + [JsonConstructor] + internal DeleteAsyncSearchRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.AsyncSearchDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -57,6 +62,14 @@ public DeleteAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "async_search.delete"; + + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs index ea208db9469..caf3ecfc88b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncSearchResponseConverter))] public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs index c2884fe1b43..5bdfb455c49 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs @@ -75,6 +75,11 @@ public GetAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. { } + [JsonConstructor] + internal GetAsyncSearchRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.AsyncSearchGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -83,6 +88,14 @@ public GetAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override string OperationName => "async_search.get"; + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies how long the async search should be available in the cluster. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs index 3dd949e280f..e7360f3539d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs @@ -22,10 +22,158 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue> propResponse = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryReadProperty(ref reader, options, PropCompletionTime, null)) + { + continue; + } + + if (propCompletionTimeInMillis.TryReadProperty(ref reader, options, PropCompletionTimeInMillis, null)) + { + continue; + } + + if (propExpirationTime.TryReadProperty(ref reader, options, PropExpirationTime, null)) + { + continue; + } + + if (propExpirationTimeInMillis.TryReadProperty(ref reader, options, PropExpirationTimeInMillis, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propResponse.TryReadProperty(ref reader, options, PropResponse, null)) + { + continue; + } + + if (propStartTime.TryReadProperty(ref reader, options, PropStartTime, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis, null, null); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime, null, null); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropResponse, value.Response, null, null); + writer.WriteProperty(options, PropStartTime, value.StartTime, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + 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 +182,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 +190,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 +200,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 +208,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.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/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs index db47e9c2ee2..fd891e1d7ce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs @@ -231,410 +231,351 @@ public sealed partial class SubmitAsyncSearchRequestParameters : RequestParamete public Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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 (propCollapse.TryReadProperty(ref reader, options, PropCollapse, null)) + { + continue; + } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propDocvalueFields.TryReadProperty(ref reader, options, PropDocvalueFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExt.TryReadProperty(ref reader, options, PropExt, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propFields.TryReadProperty(ref reader, options, PropFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndicesBoost.TryReadProperty(ref reader, options, PropIndicesBoost, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, static IDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!))) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propKnn.TryReadProperty(ref reader, options, PropKnn, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propPit.TryReadProperty(ref reader, options, PropPit, null)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPostFilter.TryReadProperty(ref reader, options, PropPostFilter, null)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRescore.TryReadProperty(ref reader, options, PropRescore, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSeqNoPrimaryTerm.TryReadProperty(ref reader, options, PropSeqNoPrimaryTerm, null)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSlice.TryReadProperty(ref reader, options, PropSlice, null)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propStats.TryReadProperty(ref reader, options, PropStats, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propTerminateAfter.TryReadProperty(ref reader, options, PropTerminateAfter, null)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTimeout.TryReadProperty(ref reader, options, PropTimeout, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTrackScores.TryReadProperty(ref reader, options, PropTrackScores, null)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackTotalHits.TryReadProperty(ref reader, options, PropTrackTotalHits, null)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropCollapse, value.Collapse, null, null); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropExt, value.Ext, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropKnn, value.Knn, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropPit, value.Pit, null, null); + writer.WriteProperty(options, PropPostFilter, value.PostFilter, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropRescore, value.Rescore, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSlice, value.Slice, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStats, value.Stats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter, null, null); + writer.WriteProperty(options, PropTimeout, value.Timeout, null, null); + writer.WriteProperty(options, PropTrackScores, value.TrackScores, null, null); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); writer.WriteEndObject(); } } @@ -657,6 +598,7 @@ public override void Write(Utf8JsonWriter writer, SubmitAsyncSearchRequest value [JsonConverter(typeof(SubmitAsyncSearchRequestConverter))] public sealed partial class SubmitAsyncSearchRequest : PlainRequest { + [JsonConstructor] public SubmitAsyncSearchRequest() { } @@ -673,12 +615,18 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) internal override string OperationName => "async_search.submit"; + /// + /// + /// A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// 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 +634,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +641,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The analyzer to use for the query string /// /// - [JsonIgnore] public string? Analyzer { get => Q("analyzer"); set => Q("analyzer", value); } /// @@ -702,7 +648,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +656,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +663,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +670,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The default operator for query string query (AND or OR) /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -735,7 +677,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +684,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +691,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +698,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +705,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +712,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +719,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +726,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +733,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Query in the Lucene query string syntax /// /// - [JsonIgnore] public string? QueryLuceneSyntax { get => Q("q"); set => Q("q", value); } /// @@ -807,7 +740,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +747,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.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); } /// @@ -823,7 +754,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A comma-separated list of specific routing values /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -831,7 +761,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Search operation type /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -839,7 +768,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A list of fields to exclude from the returned _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -847,7 +775,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A list of fields to extract and return from the _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -855,7 +782,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -863,7 +789,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify suggest mode /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -871,7 +796,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// How many suggestions to return in response /// /// - [JsonIgnore] public long? SuggestSize { get => Q("suggest_size"); set => Q("suggest_size", value); } /// @@ -879,7 +803,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +810,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +818,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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.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.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -909,7 +828,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -917,7 +835,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -925,7 +842,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -934,7 +850,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -944,9 +859,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } /// @@ -954,7 +867,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -962,8 +874,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -972,7 +882,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -981,11 +890,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; set; } - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; set; } - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -993,10 +899,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("rescore")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1005,7 +908,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1013,9 +915,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? 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 +924,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// of each hit. See Optimistic concurrency control. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -1034,12 +933,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1048,7 +943,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -1058,7 +952,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1069,10 +962,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// and stored fields in the search response. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; set; } /// @@ -1082,7 +972,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// before sorting. Defaults to 0, which does not terminate query execution early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1092,7 +981,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1100,7 +988,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.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; } /// @@ -1111,7 +998,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defaults to 10,000 hits. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1119,7 +1005,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.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/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs index 1eaf8d1c848..abaa0c421a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs @@ -22,10 +22,158 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue> propResponse = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryReadProperty(ref reader, options, PropCompletionTime, null)) + { + continue; + } + + if (propCompletionTimeInMillis.TryReadProperty(ref reader, options, PropCompletionTimeInMillis, null)) + { + continue; + } + + if (propExpirationTime.TryReadProperty(ref reader, options, PropExpirationTime, null)) + { + continue; + } + + if (propExpirationTimeInMillis.TryReadProperty(ref reader, options, PropExpirationTimeInMillis, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propResponse.TryReadProperty(ref reader, options, PropResponse, null)) + { + continue; + } + + if (propStartTime.TryReadProperty(ref reader, options, PropStartTime, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis, null, null); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime, null, null); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropResponse, value.Response, null, null); + writer.WriteProperty(options, PropStartTime, value.StartTime, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + 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 +182,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 +190,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 +200,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 +208,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.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/_Generated/Api/BulkRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs index 6e2ebd29f2a..530a690a28d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs @@ -123,6 +123,7 @@ public sealed partial class BulkRequestParameters : RequestParameters /// public sealed partial class BulkRequest : PlainRequest { + [JsonConstructor] public BulkRequest() { } @@ -139,6 +140,14 @@ public BulkRequest(Elastic.Clients.Elasticsearch.IndexName? index) : base(r => r internal override string OperationName => "bulk"; + /// + /// + /// Name of the data stream, index, or index alias to perform bulk actions on. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// If true, the response will include the ingest pipelines that were executed for each index or create. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs index a2c342a8ee7..04bce92b8ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs @@ -22,16 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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 PropItems = System.Text.Json.JsonEncodedText.Encode("items"); + 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); + LocalJsonValue propErrors = default; + LocalJsonValue propIngestTook = default; + LocalJsonValue> propItems = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryReadProperty(ref reader, options, PropErrors, null)) + { + continue; + } + + if (propIngestTook.TryReadProperty(ref reader, options, PropIngestTook, null)) + { + continue; + } + + if (propItems.TryReadProperty(ref reader, options, PropItems, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + Items = propItems.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, null, null); + writer.WriteProperty(options, PropIngestTook, value.IngestTook, null, null); + writer.WriteProperty(options, PropItems, value.Items, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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 IReadOnlyCollection Items { get; init; } public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollRequest.g.cs index 156d7b50847..710d8874650 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class ClearScrollRequestParameters : RequestParameters /// public sealed partial class ClearScrollRequest : PlainRequest { + [JsonConstructor] + internal ClearScrollRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceClearScroll; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs index 29bfde63e45..fbd8eddac09 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propNumFreed = default; + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryReadProperty(ref reader, options, PropNumFreed, null)) + { + continue; + } + + if (propSucceeded.TryReadProperty(ref reader, options, PropSucceeded, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSucceeded, value.Succeeded, null, null); + 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/_Generated/Api/ClosePointInTimeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeRequest.g.cs index 4bc64124f7a..c6eefce27bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeRequest.g.cs @@ -47,6 +47,11 @@ public sealed partial class ClosePointInTimeRequestParameters : RequestParameter /// public sealed partial class ClosePointInTimeRequest : PlainRequest { + [JsonConstructor] + internal ClosePointInTimeRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceClosePointInTime; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs index 1fdf5b5b3ae..a92d50a5aaa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propNumFreed = default; + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryReadProperty(ref reader, options, PropNumFreed, null)) + { + continue; + } + + if (propSucceeded.TryReadProperty(ref reader, options, PropSucceeded, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSucceeded, value.Succeeded, null, null); + 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/_Generated/Api/Cluster/AllocationExplainRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainRequest.g.cs index 23e668b1bcd..89f9b64d515 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainRequest.g.cs @@ -58,6 +58,11 @@ public sealed partial class AllocationExplainRequestParameters : RequestParamete /// public sealed partial class AllocationExplainRequest : PlainRequest { + [JsonConstructor] + internal AllocationExplainRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterAllocationExplain; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs index a17abac6f3c..221408803a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs @@ -22,60 +22,316 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllocateExplanation = default; + LocalJsonValue propAllocationDelay = default; + LocalJsonValue propAllocationDelayInMillis = default; + LocalJsonValue propCanAllocate = default; + LocalJsonValue propCanMoveToOtherNode = default; + LocalJsonValue propCanRebalanceCluster = default; + LocalJsonValue?> propCanRebalanceClusterDecisions = default; + LocalJsonValue propCanRebalanceToOtherNode = default; + LocalJsonValue?> propCanRemainDecisions = default; + LocalJsonValue propCanRemainOnCurrentNode = default; + LocalJsonValue propClusterInfo = default; + LocalJsonValue propConfiguredDelay = default; + LocalJsonValue propConfiguredDelayInMillis = default; + LocalJsonValue propCurrentNode = default; + LocalJsonValue propCurrentState = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMoveExplanation = default; + LocalJsonValue?> propNodeAllocationDecisions = default; + LocalJsonValue propNote = default; + LocalJsonValue propPrimary = default; + LocalJsonValue propRebalanceExplanation = default; + LocalJsonValue propRemainingDelay = default; + LocalJsonValue propRemainingDelayInMillis = default; + LocalJsonValue propShard = default; + LocalJsonValue propUnassignedInfo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllocateExplanation.TryReadProperty(ref reader, options, PropAllocateExplanation, null)) + { + continue; + } + + if (propAllocationDelay.TryReadProperty(ref reader, options, PropAllocationDelay, null)) + { + continue; + } + + if (propAllocationDelayInMillis.TryReadProperty(ref reader, options, PropAllocationDelayInMillis, null)) + { + continue; + } + + if (propCanAllocate.TryReadProperty(ref reader, options, PropCanAllocate, null)) + { + continue; + } + + if (propCanMoveToOtherNode.TryReadProperty(ref reader, options, PropCanMoveToOtherNode, null)) + { + continue; + } + + if (propCanRebalanceCluster.TryReadProperty(ref reader, options, PropCanRebalanceCluster, null)) + { + continue; + } + + if (propCanRebalanceClusterDecisions.TryReadProperty(ref reader, options, PropCanRebalanceClusterDecisions, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCanRebalanceToOtherNode.TryReadProperty(ref reader, options, PropCanRebalanceToOtherNode, null)) + { + continue; + } + + if (propCanRemainDecisions.TryReadProperty(ref reader, options, PropCanRemainDecisions, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCanRemainOnCurrentNode.TryReadProperty(ref reader, options, PropCanRemainOnCurrentNode, null)) + { + continue; + } + + if (propClusterInfo.TryReadProperty(ref reader, options, PropClusterInfo, null)) + { + continue; + } + + if (propConfiguredDelay.TryReadProperty(ref reader, options, PropConfiguredDelay, null)) + { + continue; + } + + if (propConfiguredDelayInMillis.TryReadProperty(ref reader, options, PropConfiguredDelayInMillis, null)) + { + continue; + } + + if (propCurrentNode.TryReadProperty(ref reader, options, PropCurrentNode, null)) + { + continue; + } + + if (propCurrentState.TryReadProperty(ref reader, options, PropCurrentState, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMoveExplanation.TryReadProperty(ref reader, options, PropMoveExplanation, null)) + { + continue; + } + + if (propNodeAllocationDecisions.TryReadProperty(ref reader, options, PropNodeAllocationDecisions, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNote.TryReadProperty(ref reader, options, PropNote, null)) + { + continue; + } + + if (propPrimary.TryReadProperty(ref reader, options, PropPrimary, null)) + { + continue; + } + + if (propRebalanceExplanation.TryReadProperty(ref reader, options, PropRebalanceExplanation, null)) + { + continue; + } + + if (propRemainingDelay.TryReadProperty(ref reader, options, PropRemainingDelay, null)) + { + continue; + } + + if (propRemainingDelayInMillis.TryReadProperty(ref reader, options, PropRemainingDelayInMillis, null)) + { + continue; + } + + if (propShard.TryReadProperty(ref reader, options, PropShard, null)) + { + continue; + } + + if (propUnassignedInfo.TryReadProperty(ref reader, options, PropUnassignedInfo, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAllocationDelay, value.AllocationDelay, null, null); + writer.WriteProperty(options, PropAllocationDelayInMillis, value.AllocationDelayInMillis, null, null); + writer.WriteProperty(options, PropCanAllocate, value.CanAllocate, null, null); + writer.WriteProperty(options, PropCanMoveToOtherNode, value.CanMoveToOtherNode, null, null); + writer.WriteProperty(options, PropCanRebalanceCluster, value.CanRebalanceCluster, null, null); + writer.WriteProperty(options, PropCanRebalanceClusterDecisions, value.CanRebalanceClusterDecisions, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCanRebalanceToOtherNode, value.CanRebalanceToOtherNode, null, null); + writer.WriteProperty(options, PropCanRemainDecisions, value.CanRemainDecisions, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCanRemainOnCurrentNode, value.CanRemainOnCurrentNode, null, null); + writer.WriteProperty(options, PropClusterInfo, value.ClusterInfo, null, null); + writer.WriteProperty(options, PropConfiguredDelay, value.ConfiguredDelay, null, null); + writer.WriteProperty(options, PropConfiguredDelayInMillis, value.ConfiguredDelayInMillis, null, null); + writer.WriteProperty(options, PropCurrentNode, value.CurrentNode, null, null); + writer.WriteProperty(options, PropCurrentState, value.CurrentState, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMoveExplanation, value.MoveExplanation, null, null); + writer.WriteProperty(options, PropNodeAllocationDecisions, value.NodeAllocationDecisions, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNote, value.Note, null, null); + writer.WriteProperty(options, PropPrimary, value.Primary, null, null); + writer.WriteProperty(options, PropRebalanceExplanation, value.RebalanceExplanation, null, null); + writer.WriteProperty(options, PropRemainingDelay, value.RemainingDelay, null, null); + writer.WriteProperty(options, PropRemainingDelayInMillis, value.RemainingDelayInMillis, null, null); + writer.WriteProperty(options, PropShard, value.Shard, null, null); + writer.WriteProperty(options, PropUnassignedInfo, value.UnassignedInfo, null, null); + 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.Duration? AllocationDelay { get; init; } - [JsonInclude, JsonPropertyName("allocation_delay_in_millis")] public long? AllocationDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("can_allocate")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanAllocate { get; init; } - [JsonInclude, JsonPropertyName("can_move_to_other_node")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanMoveToOtherNode { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_cluster")] public Elastic.Clients.Elasticsearch.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.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.Cluster.Decision? CanRemainOnCurrentNode { get; init; } - [JsonInclude, JsonPropertyName("cluster_info")] public Elastic.Clients.Elasticsearch.Cluster.ClusterInfo? ClusterInfo { get; init; } - [JsonInclude, JsonPropertyName("configured_delay")] public Elastic.Clients.Elasticsearch.Duration? ConfiguredDelay { get; init; } - [JsonInclude, JsonPropertyName("configured_delay_in_millis")] public long? ConfiguredDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("current_node")] public Elastic.Clients.Elasticsearch.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.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.Cluster.UnassignedInformation? UnassignedInfo { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs index 64573f02d86..37d1048cfba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs @@ -46,6 +46,11 @@ public ClusterInfoRequest(IReadOnlyCollection ApiUrlLookup.ClusterInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,14 @@ public ClusterInfoRequest(IReadOnlyCollection false; internal override string OperationName => "cluster.info"; + + /// + /// + /// Limits the information returned to the specific target. Supports a comma-separated list, such as http,ingest. + /// + /// + [JsonIgnore] + public ICollection Target { get => P>("target"); set => PR("target", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs index 3a0c28fa600..80eee7c1ce0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue propHttp = default; + LocalJsonValue propIngest = default; + LocalJsonValue propScript = default; + LocalJsonValue?> propThreadPool = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propHttp.TryReadProperty(ref reader, options, PropHttp, null)) + { + continue; + } + + if (propIngest.TryReadProperty(ref reader, options, PropIngest, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propThreadPool.TryReadProperty(ref reader, options, PropThreadPool, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropHttp, value.Http, null, null); + writer.WriteProperty(options, PropIngest, value.Ingest, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + 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.Nodes.Http? Http { get; init; } - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Nodes.Ingest? Ingest { get; init; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Cluster/ClusterStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs index f9395e795b6..87bf0803fe8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs @@ -57,6 +57,7 @@ public sealed partial class ClusterStatsRequestParameters : RequestParameters /// public sealed partial class ClusterStatsRequest : PlainRequest { + [JsonConstructor] public ClusterStatsRequest() { } @@ -73,6 +74,14 @@ public ClusterStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base internal override string OperationName => "cluster.stats"; + /// + /// + /// Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Include remote cluster data into the response diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs index 75d8dfb2977..1476a8de543 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs @@ -22,10 +22,111 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue propClusterUuid = default; + LocalJsonValue propIndices = default; + LocalJsonValue propNodes = default; + LocalJsonValue propNodeStats = default; + LocalJsonValue propStatus = default; + LocalJsonValue propTimestamp = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propClusterUuid.TryReadProperty(ref reader, options, PropClusterUuid, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, null)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (propTimestamp.TryReadProperty(ref reader, options, PropTimestamp, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, null); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + writer.WriteProperty(options, PropStatus, value.Status, null, null); + writer.WriteProperty(options, PropTimestamp, value.Timestamp, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClusterStatsResponseConverter))] public sealed partial class ClusterStatsResponse : ElasticsearchResponse { /// @@ -33,7 +134,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 +141,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Unique identifier for the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } /// @@ -49,7 +148,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about indices with shards assigned to selected nodes. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Cluster.ClusterIndices Indices { get; init; } /// @@ -57,7 +155,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.Cluster.ClusterNodes Nodes { get; init; } /// @@ -65,7 +162,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.NodeStatistics? NodeStats { get; init; } /// @@ -73,7 +169,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.HealthStatus Status { get; init; } /// @@ -81,6 +176,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/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs index b0db2cd21b4..3cb2ec82b08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs @@ -62,6 +62,11 @@ public DeleteComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) { } + [JsonConstructor] + internal DeleteComponentTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterDeleteComponentTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -70,6 +75,14 @@ public DeleteComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) internal override string OperationName => "cluster.delete_component_template"; + /// + /// + /// Comma-separated list or wildcard expression of component template names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs index 7f8b65c9cbe..c9fbb212cc6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteComponentTemplateResponseConverter))] public sealed partial class DeleteComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Cluster/DeleteVotingConfigExclusionsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteVotingConfigExclusionsRequest.g.cs index b666916f7c7..0a964010043 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteVotingConfigExclusionsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteVotingConfigExclusionsRequest.g.cs @@ -53,6 +53,11 @@ public sealed partial class DeleteVotingConfigExclusionsRequestParameters : Requ /// public sealed partial class DeleteVotingConfigExclusionsRequest : PlainRequest { + [JsonConstructor] + internal DeleteVotingConfigExclusionsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterDeleteVotingConfigExclusions; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs index 8f2da988a43..b6632950430 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs @@ -62,6 +62,11 @@ public ExistsComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) { } + [JsonConstructor] + internal ExistsComponentTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterExistsComponentTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -70,6 +75,15 @@ public ExistsComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) internal override string OperationName => "cluster.exists_component_template"; + /// + /// + /// Comma-separated list of component template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, the request retrieves information from the local node only. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsRequest.g.cs index c4fc5d41325..4db023e557c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsRequest.g.cs @@ -71,6 +71,11 @@ public sealed partial class GetClusterSettingsRequestParameters : RequestParamet /// public sealed partial class GetClusterSettingsRequest : PlainRequest { + [JsonConstructor] + internal GetClusterSettingsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterGetSettings; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs index febb734d698..1af5497ed1d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propDefaults = default; + LocalJsonValue> propPersistent = default; + LocalJsonValue> propTransient = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryReadProperty(ref reader, options, PropDefaults, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propPersistent.TryReadProperty(ref reader, options, PropPersistent, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propTransient.TryReadProperty(ref reader, options, PropTransient, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropPersistent, value.Persistent, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTransient, value.Transient, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + 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/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs index a344e42d854..27ad57a89e6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs @@ -71,6 +71,7 @@ public sealed partial class GetComponentTemplateRequestParameters : RequestParam /// public sealed partial class GetComponentTemplateRequest : PlainRequest { + [JsonConstructor] public GetComponentTemplateRequest() { } @@ -87,6 +88,15 @@ public GetComponentTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : b internal override string OperationName => "cluster.get_component_template"; + /// + /// + /// Comma-separated list of component template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs index 629ad116f00..d496809982b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propComponentTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComponentTemplates.TryReadProperty(ref reader, options, PropComponentTemplates, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Cluster/HealthRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs index 07c6a721bf8..d4a65f7dd06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs @@ -128,6 +128,7 @@ public sealed partial class HealthRequestParameters : RequestParameters /// public sealed partial class HealthRequest : PlainRequest { + [JsonConstructor] public HealthRequest() { } @@ -144,6 +145,14 @@ public HealthRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "cluster.health"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indices in a cluster, omit this parameter or use _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to expand wildcard expression to concrete indices that are open, closed or both. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs index e3fca0ec657..e4f9ee14b49 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs @@ -22,10 +22,221 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propActivePrimaryShards = default; + LocalJsonValue propActiveShards = default; + LocalJsonValue propActiveShardsPercentAsNumber = default; + LocalJsonValue propClusterName = default; + LocalJsonValue propDelayedUnassignedShards = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propInitializingShards = default; + LocalJsonValue propNumberOfDataNodes = default; + LocalJsonValue propNumberOfInFlightFetch = default; + LocalJsonValue propNumberOfNodes = default; + LocalJsonValue propNumberOfPendingTasks = default; + LocalJsonValue propRelocatingShards = default; + LocalJsonValue propStatus = default; + LocalJsonValue propTaskMaxWaitingInQueue = default; + LocalJsonValue propTaskMaxWaitingInQueueMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propUnassignedPrimaryShards = default; + LocalJsonValue propUnassignedShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActivePrimaryShards.TryReadProperty(ref reader, options, PropActivePrimaryShards, null)) + { + continue; + } + + if (propActiveShards.TryReadProperty(ref reader, options, PropActiveShards, null)) + { + continue; + } + + if (propActiveShardsPercentAsNumber.TryReadProperty(ref reader, options, PropActiveShardsPercentAsNumber, null)) + { + continue; + } + + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propDelayedUnassignedShards.TryReadProperty(ref reader, options, PropDelayedUnassignedShards, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propInitializingShards.TryReadProperty(ref reader, options, PropInitializingShards, null)) + { + continue; + } + + if (propNumberOfDataNodes.TryReadProperty(ref reader, options, PropNumberOfDataNodes, null)) + { + continue; + } + + if (propNumberOfInFlightFetch.TryReadProperty(ref reader, options, PropNumberOfInFlightFetch, null)) + { + continue; + } + + if (propNumberOfNodes.TryReadProperty(ref reader, options, PropNumberOfNodes, null)) + { + continue; + } + + if (propNumberOfPendingTasks.TryReadProperty(ref reader, options, PropNumberOfPendingTasks, null)) + { + continue; + } + + if (propRelocatingShards.TryReadProperty(ref reader, options, PropRelocatingShards, null)) + { + continue; + } + + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (propTaskMaxWaitingInQueue.TryReadProperty(ref reader, options, PropTaskMaxWaitingInQueue, null)) + { + continue; + } + + if (propTaskMaxWaitingInQueueMillis.TryReadProperty(ref reader, options, PropTaskMaxWaitingInQueueMillis, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propUnassignedPrimaryShards.TryReadProperty(ref reader, options, PropUnassignedPrimaryShards, null)) + { + continue; + } + + if (propUnassignedShards.TryReadProperty(ref reader, options, PropUnassignedShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropActiveShards, value.ActiveShards, null, null); + writer.WriteProperty(options, PropActiveShardsPercentAsNumber, value.ActiveShardsPercentAsNumber, null, null); + writer.WriteProperty(options, PropClusterName, value.ClusterName, null, null); + writer.WriteProperty(options, PropDelayedUnassignedShards, value.DelayedUnassignedShards, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropInitializingShards, value.InitializingShards, null, null); + writer.WriteProperty(options, PropNumberOfDataNodes, value.NumberOfDataNodes, null, null); + writer.WriteProperty(options, PropNumberOfInFlightFetch, value.NumberOfInFlightFetch, null, null); + writer.WriteProperty(options, PropNumberOfNodes, value.NumberOfNodes, null, null); + writer.WriteProperty(options, PropNumberOfPendingTasks, value.NumberOfPendingTasks, null, null); + writer.WriteProperty(options, PropRelocatingShards, value.RelocatingShards, null, null); + writer.WriteProperty(options, PropStatus, value.Status, null, null); + writer.WriteProperty(options, PropTaskMaxWaitingInQueue, value.TaskMaxWaitingInQueue, null, null); + writer.WriteProperty(options, PropTaskMaxWaitingInQueueMillis, value.TaskMaxWaitingInQueueMillis, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropUnassignedPrimaryShards, value.UnassignedPrimaryShards, null, null); + writer.WriteProperty(options, PropUnassignedShards, value.UnassignedShards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HealthResponseConverter))] public sealed partial class HealthResponse : ElasticsearchResponse { /// @@ -33,7 +244,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 +251,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 +258,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 +265,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The name of the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -65,10 +272,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.Cluster.IndexHealthStats))] public IReadOnlyDictionary? Indices { get; init; } /// @@ -76,7 +280,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 +287,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 +294,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 +301,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 +308,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 +315,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.HealthStatus Status { get; init; } /// @@ -126,7 +323,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.Duration? TaskMaxWaitingInQueue { get; init; } /// @@ -134,7 +330,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 +337,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 +344,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 +351,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/_Generated/Api/Cluster/PendingTasksRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksRequest.g.cs index ed40db21041..3b0e83bcf33 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksRequest.g.cs @@ -62,6 +62,11 @@ public sealed partial class PendingTasksRequestParameters : RequestParameters /// public sealed partial class PendingTasksRequest : PlainRequest { + [JsonConstructor] + internal PendingTasksRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterPendingTasks; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs index 024b4bad879..6ae324d6975 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTasks.TryReadProperty(ref reader, options, PropTasks, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Cluster/PostVotingConfigExclusionsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PostVotingConfigExclusionsRequest.g.cs index 75da7c39dae..905a69e9c60 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PostVotingConfigExclusionsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PostVotingConfigExclusionsRequest.g.cs @@ -86,6 +86,11 @@ public sealed partial class PostVotingConfigExclusionsRequestParameters : Reques /// public sealed partial class PostVotingConfigExclusionsRequest : PlainRequest { + [JsonConstructor] + internal PostVotingConfigExclusionsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterPostVotingConfigExclusions; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs index 2670838909f..27afa57039d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs @@ -78,6 +78,11 @@ public PutComponentTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : ba { } + [JsonConstructor] + internal PutComponentTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.ClusterPutComponentTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -86,6 +91,18 @@ public PutComponentTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "cluster.put_component_template"; + /// + /// + /// Name of the component template to create. + /// Elasticsearch includes the following built-in component templates: logs-mappings; logs-settings; metrics-mappings; metrics-settings;synthetics-mapping; synthetics-settings. + /// Elastic Agent uses these templates to configure backing indices for its data streams. + /// If you use Elastic Agent and want to overwrite one of these templates, set the version for your replacement template higher than the current version. + /// If you don’t use Elastic Agent and want to disable all built-in component and index templates, set stack.templates.enabled to false using the cluster update settings API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, this request cannot replace or update existing component templates. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs index 5b48a459f7a..623a80de8f5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutComponentTemplateResponseConverter))] public sealed partial class PutComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/CountRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs index a6dcb0989ca..c2b6ae72941 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs @@ -149,6 +149,7 @@ public sealed partial class CountRequestParameters : RequestParameters /// public partial class CountRequest : PlainRequest { + [JsonConstructor] public CountRequest() { } @@ -165,6 +166,16 @@ public CountRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "count"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs index e225c0dee65..53c58a2d501 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propCount = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + 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.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs index e9cf25961c7..59e6ff4cd61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs @@ -87,6 +87,36 @@ public sealed partial class CreateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } } +internal sealed partial class CreateRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + public override CreateRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new CreateRequest { Document = reader.ReadValue(options, static TDocument (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker))!) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Document, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + } +} + +internal sealed partial class CreateRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(CreateRequest<>); + } + + 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(CreateRequestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Index a document. @@ -94,12 +124,18 @@ 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 +[JsonConverter(typeof(CreateRequestConverterFactory))] +public sealed partial class CreateRequest : PlainRequest { public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", index).Required("id", id)) { } + [JsonConstructor] + internal CreateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceCreate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -108,6 +144,22 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "create"; + /// + /// + /// Unique identifier for the document. + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the data stream or index to target. + /// If the target doesn’t exist and matches the name or wildcard (*) pattern of an index template with a data_stream definition, this request creates the data stream. + /// If the target doesn’t exist and doesn’t match a data stream template, this request creates the index. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// ID of the pipeline to use to preprocess incoming documents. @@ -115,7 +167,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// If a final pipeline is configured it will always run, regardless of the value of this parameter. /// /// - [JsonIgnore] public string? Pipeline { get => Q("pipeline"); set => Q("pipeline", value); } /// @@ -124,7 +175,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Valid values: true, false, wait_for. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } /// @@ -132,7 +182,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -140,7 +189,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -149,7 +197,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// The specified version must match the current version of the document for the request to succeed. /// /// - [JsonIgnore] public long? Version { get => Q("version"); set => Q("version", value); } /// @@ -157,7 +204,6 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specific version type: external, external_gte. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } /// @@ -166,15 +212,8 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } - [JsonIgnore] public TDocument Document { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - settings.SourceSerializer.Serialize(Document, writer); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs index edeaeb613d2..90a036fea2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs @@ -22,26 +22,129 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/CrossClusterReplication/CcrStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsRequest.g.cs index 0c05bca66b6..9af3c6c66ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class CcrStatsRequestParameters : RequestParameters /// public sealed partial class CcrStatsRequest : PlainRequest { + [JsonConstructor] + internal CcrStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs index 774d051bff4..01b54b9f8e1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class CcrStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAutoFollowStats = System.Text.Json.JsonEncodedText.Encode("auto_follow_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFollowStats = System.Text.Json.JsonEncodedText.Encode("follow_stats"); + + public override CcrStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAutoFollowStats = default; + LocalJsonValue propFollowStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAutoFollowStats.TryReadProperty(ref reader, options, PropAutoFollowStats, null)) + { + continue; + } + + if (propFollowStats.TryReadProperty(ref reader, options, PropFollowStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CcrStatsResponse + { + AutoFollowStats = propAutoFollowStats.Value +, + FollowStats = propFollowStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CcrStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAutoFollowStats, value.AutoFollowStats, null, null); + writer.WriteProperty(options, PropFollowStats, value.FollowStats, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CcrStatsResponseConverter))] public sealed partial class CcrStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("auto_follow_stats")] public Elastic.Clients.Elasticsearch.CrossClusterReplication.AutoFollowStats AutoFollowStats { get; init; } - [JsonInclude, JsonPropertyName("follow_stats")] public Elastic.Clients.Elasticsearch.CrossClusterReplication.FollowStats FollowStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs index 838922632ca..d4f77ff30df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs @@ -46,6 +46,11 @@ public DeleteAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal DeleteAutoFollowPatternRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationDeleteAutoFollowPattern; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,14 @@ public DeleteAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.delete_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs index 99617d5ed3d..a16fdf4ffbe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class DeleteAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAutoFollowPatternResponseConverter))] public sealed partial class DeleteAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class DeleteAutoFollowPatternResponse : 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/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs index 75a456deb2a..832a37d08c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs @@ -47,6 +47,11 @@ public FollowInfoRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r { } + [JsonConstructor] + internal FollowInfoRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationFollowInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -54,6 +59,14 @@ public FollowInfoRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override bool SupportsBody => false; internal override string OperationName => "ccr.follow_info"; + + /// + /// + /// A comma-separated list of index patterns; use _all to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs index 54fcd7202df..22ccb83c1ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFollowerIndices = System.Text.Json.JsonEncodedText.Encode("follower_indices"); + + public override FollowInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFollowerIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFollowerIndices.TryReadProperty(ref reader, options, PropFollowerIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowInfoResponse + { + FollowerIndices = propFollowerIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFollowerIndices, value.FollowerIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowInfoResponseConverter))] public sealed partial class FollowInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("follower_indices")] public IReadOnlyCollection FollowerIndices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs index 713e143d421..a033e08492f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs @@ -56,6 +56,11 @@ public FollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => { } + [JsonConstructor] + internal FollowRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationFollow; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -64,6 +69,14 @@ public FollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => internal override string OperationName => "ccr.follow"; + /// + /// + /// The name of the follower index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the number of shards to wait on being active before responding. This defaults to waiting on none of the shards to be diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs index c30f351af3c..fa475174b13 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFollowIndexCreated = System.Text.Json.JsonEncodedText.Encode("follow_index_created"); + private static readonly System.Text.Json.JsonEncodedText PropFollowIndexShardsAcked = System.Text.Json.JsonEncodedText.Encode("follow_index_shards_acked"); + private static readonly System.Text.Json.JsonEncodedText PropIndexFollowingStarted = System.Text.Json.JsonEncodedText.Encode("index_following_started"); + + public override FollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFollowIndexCreated = default; + LocalJsonValue propFollowIndexShardsAcked = default; + LocalJsonValue propIndexFollowingStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFollowIndexCreated.TryReadProperty(ref reader, options, PropFollowIndexCreated, null)) + { + continue; + } + + if (propFollowIndexShardsAcked.TryReadProperty(ref reader, options, PropFollowIndexShardsAcked, null)) + { + continue; + } + + if (propIndexFollowingStarted.TryReadProperty(ref reader, options, PropIndexFollowingStarted, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowResponse + { + FollowIndexCreated = propFollowIndexCreated.Value +, + FollowIndexShardsAcked = propFollowIndexShardsAcked.Value +, + IndexFollowingStarted = propIndexFollowingStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFollowIndexCreated, value.FollowIndexCreated, null, null); + writer.WriteProperty(options, PropFollowIndexShardsAcked, value.FollowIndexShardsAcked, null, null); + writer.WriteProperty(options, PropIndexFollowingStarted, value.IndexFollowingStarted, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowResponseConverter))] public sealed partial class FollowResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("follow_index_created")] public bool FollowIndexCreated { get; init; } - [JsonInclude, JsonPropertyName("follow_index_shards_acked")] public bool FollowIndexShardsAcked { get; init; } - [JsonInclude, JsonPropertyName("index_following_started")] public bool IndexFollowingStarted { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs index a08fd5c57f4..8fc86f9c184 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs @@ -47,6 +47,11 @@ public FollowStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( { } + [JsonConstructor] + internal FollowStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationFollowStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -54,6 +59,14 @@ public FollowStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( internal override bool SupportsBody => false; internal override string OperationName => "ccr.follow_stats"; + + /// + /// + /// A comma-separated list of index patterns; use _all to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs index 46fc142371f..139d11e892a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override FollowStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowStatsResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowStatsResponseConverter))] public sealed partial class FollowStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs index 83afef716e7..d1e9e0e3fa5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs @@ -58,6 +58,11 @@ public ForgetFollowerRequest(Elastic.Clients.Elasticsearch.IndexName index) : ba { } + [JsonConstructor] + internal ForgetFollowerRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationForgetFollower; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -66,6 +71,13 @@ public ForgetFollowerRequest(Elastic.Clients.Elasticsearch.IndexName index) : ba internal override string OperationName => "ccr.forget_follower"; + /// + /// + /// the name of the leader index for which specified follower retention leases should be removed + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("follower_cluster")] public string? FollowerCluster { get; set; } [JsonInclude, JsonPropertyName("follower_index")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs index cb86186b4b9..eaa000ee433 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ForgetFollowerResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ForgetFollowerResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForgetFollowerResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForgetFollowerResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForgetFollowerResponseConverter))] public sealed partial class ForgetFollowerResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs index 0d67104509e..0123e02e850 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs @@ -42,6 +42,7 @@ public sealed partial class GetAutoFollowPatternRequestParameters : RequestParam /// public sealed partial class GetAutoFollowPatternRequest : PlainRequest { + [JsonConstructor] public GetAutoFollowPatternRequest() { } @@ -57,6 +58,14 @@ public GetAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name? name) : b internal override bool SupportsBody => false; internal override string OperationName => "ccr.get_auto_follow_pattern"; + + /// + /// + /// Specifies the auto-follow pattern collection that you want to retrieve. If you do not specify a name, the API returns information for all collections. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs index 7e0562b9122..0f4f6452515 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class GetAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPatterns = System.Text.Json.JsonEncodedText.Encode("patterns"); + + public override GetAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propPatterns = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPatterns.TryReadProperty(ref reader, options, PropPatterns, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAutoFollowPatternResponse + { + Patterns = propPatterns.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPatterns, value.Patterns, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAutoFollowPatternResponseConverter))] public sealed partial class GetAutoFollowPatternResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("patterns")] public IReadOnlyCollection Patterns { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs index 6d1d06ba408..259f4ea67c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs @@ -53,6 +53,11 @@ public PauseAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal PauseAutoFollowPatternRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationPauseAutoFollowPattern; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -60,6 +65,14 @@ public PauseAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.pause_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern that should pause discovering new indices to follow. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs index bb6d5fb3a2e..673d8a8c0da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PauseAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PauseAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PauseAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PauseAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PauseAutoFollowPatternResponseConverter))] public sealed partial class PauseAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class PauseAutoFollowPatternResponse : ElasticsearchRespon /// 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/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs index ba974a7ce62..f3b0d933836 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs @@ -49,6 +49,11 @@ public PauseFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( { } + [JsonConstructor] + internal PauseFollowRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationPauseFollow; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -56,6 +61,14 @@ public PauseFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override bool SupportsBody => false; internal override string OperationName => "ccr.pause_follow"; + + /// + /// + /// The name of the follower index that should pause following its leader index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs index 1d2496b5ce9..d673bc340ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PauseFollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PauseFollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PauseFollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PauseFollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PauseFollowResponseConverter))] public sealed partial class PauseFollowResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class PauseFollowResponse : 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/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs index 0d2b49c3377..06a8a0b0d83 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs @@ -52,6 +52,11 @@ public PutAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : ba { } + [JsonConstructor] + internal PutAutoFollowPatternRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationPutAutoFollowPattern; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -60,6 +65,14 @@ public PutAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "ccr.put_auto_follow_pattern"; + /// + /// + /// The name of the collection of auto-follow patterns. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// The name of follower index. The template {{leader_index}} can be used to derive the name of the follower index from the name of the leader index. When following a data stream, use {{leader_index}}; CCR does not support changes to the names of a follower data stream’s backing indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs index 12a5140d0b3..cbb49eb8884 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PutAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutAutoFollowPatternResponseConverter))] public sealed partial class PutAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class PutAutoFollowPatternResponse : 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/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs index 33dd4afe9a4..8f82bd208f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs @@ -48,6 +48,11 @@ public ResumeAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal ResumeAutoFollowPatternRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationResumeAutoFollowPattern; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -55,6 +60,14 @@ public ResumeAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.resume_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern to resume discovering new indices to follow. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs index c7cab6b189b..cc410389e25 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ResumeAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResumeAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResumeAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResumeAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResumeAutoFollowPatternResponseConverter))] public sealed partial class ResumeAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class ResumeAutoFollowPatternResponse : 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/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs index ab0686ccb90..8a5ae6728dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs @@ -49,6 +49,11 @@ public ResumeFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base { } + [JsonConstructor] + internal ResumeFollowRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationResumeFollow; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -57,6 +62,13 @@ public ResumeFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base internal override string OperationName => "ccr.resume_follow"; + /// + /// + /// The name of the follow index to resume following. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("max_outstanding_read_requests")] public long? MaxOutstandingReadRequests { get; set; } [JsonInclude, JsonPropertyName("max_outstanding_write_requests")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs index 0a11009556d..abe16dfb51e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ResumeFollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResumeFollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResumeFollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResumeFollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResumeFollowResponseConverter))] public sealed partial class ResumeFollowResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class ResumeFollowResponse : 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/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs index ab1fab0076b..90c6496eb3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs @@ -51,6 +51,11 @@ public UnfollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r = { } + [JsonConstructor] + internal UnfollowRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationUnfollow; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -58,6 +63,14 @@ public UnfollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "ccr.unfollow"; + + /// + /// + /// The name of the follower index that should be turned into a regular index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs index ee58b3bcbb8..0d365102d42 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class UnfollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UnfollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnfollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnfollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UnfollowResponseConverter))] public sealed partial class UnfollowResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class UnfollowResponse : 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/_Generated/Api/DanglingIndices/ListDanglingIndicesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesRequest.g.cs index 651b65cef03..64c211f5b3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesRequest.g.cs @@ -48,6 +48,11 @@ public sealed partial class ListDanglingIndicesRequestParameters : RequestParame /// public sealed partial class ListDanglingIndicesRequest : PlainRequest { + [JsonConstructor] + internal ListDanglingIndicesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.DanglingIndicesListDanglingIndices; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs index b84dd6c6f7f..db8042ef3ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.DanglingIndices; +internal sealed partial class ListDanglingIndicesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDanglingIndices = System.Text.Json.JsonEncodedText.Encode("dangling_indices"); + + public override ListDanglingIndicesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDanglingIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDanglingIndices.TryReadProperty(ref reader, options, PropDanglingIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListDanglingIndicesResponse + { + DanglingIndices = propDanglingIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListDanglingIndicesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDanglingIndices, value.DanglingIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListDanglingIndicesResponseConverter))] public sealed partial class ListDanglingIndicesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("dangling_indices")] public IReadOnlyCollection DanglingIndices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs index 34541aa28c1..1ef92bdda10 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs @@ -256,6 +256,11 @@ public DeleteByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas { } + [JsonConstructor] + internal DeleteByQueryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceDeleteByQuery; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -264,6 +269,16 @@ public DeleteByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas internal override string OperationName => "delete_by_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs index 04d1a451f0d..e01db59e2ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs @@ -22,42 +22,217 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propBatches = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propSliceId = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottled = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntil = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryReadProperty(ref reader, options, PropBatches, null)) + { + continue; + } + + if (propDeleted.TryReadProperty(ref reader, options, PropDeleted, null)) + { + continue; + } + + if (propFailures.TryReadProperty(ref reader, options, PropFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNoops.TryReadProperty(ref reader, options, PropNoops, null)) + { + continue; + } + + if (propRequestsPerSecond.TryReadProperty(ref reader, options, PropRequestsPerSecond, null)) + { + continue; + } + + if (propRetries.TryReadProperty(ref reader, options, PropRetries, null)) + { + continue; + } + + if (propSliceId.TryReadProperty(ref reader, options, PropSliceId, null)) + { + continue; + } + + if (propTask.TryReadProperty(ref reader, options, PropTask, null)) + { + continue; + } + + if (propThrottled.TryReadProperty(ref reader, options, PropThrottled, null)) + { + continue; + } + + if (propThrottledMillis.TryReadProperty(ref reader, options, PropThrottledMillis, null)) + { + continue; + } + + if (propThrottledUntil.TryReadProperty(ref reader, options, PropThrottledUntil, null)) + { + continue; + } + + if (propThrottledUntilMillis.TryReadProperty(ref reader, options, PropThrottledUntilMillis, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (propVersionConflicts.TryReadProperty(ref reader, options, PropVersionConflicts, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDeleted, value.Deleted, null, null); + writer.WriteProperty(options, PropFailures, value.Failures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNoops, value.Noops, null, null); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond, null, null); + writer.WriteProperty(options, PropRetries, value.Retries, null, null); + writer.WriteProperty(options, PropSliceId, value.SliceId, null, null); + writer.WriteProperty(options, PropTask, value.Task, null, null); + writer.WriteProperty(options, PropThrottled, value.Throttled, null, null); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis, null, null); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil, null, null); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts, null, null); + 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.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs index 2b09f0d917c..62ba2e55d84 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs @@ -55,6 +55,11 @@ public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.TaskId taskI { } + [JsonConstructor] + internal DeleteByQueryRethrottleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceDeleteByQueryRethrottle; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -63,6 +68,14 @@ public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.TaskId taskI internal override string OperationName => "delete_by_query_rethrottle"; + /// + /// + /// The ID for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.TaskId TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs index 1835de4dc4b..0f0c4c00142 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs @@ -22,13 +22,83 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryReadProperty(ref reader, options, PropNodeFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propTaskFailures.TryReadProperty(ref reader, options, PropTaskFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTasks.TryReadProperty(ref reader, options, PropTasks, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTasks, value.Tasks, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteByQueryRethrottleResponseConverter))] public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +106,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 +115,5 @@ public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchRespo /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs index 479d7e6c9a3..c9e8514bc2d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs @@ -104,6 +104,11 @@ public DeleteRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie { } + [JsonConstructor] + internal DeleteRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -112,6 +117,22 @@ public DeleteRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "delete"; + /// + /// + /// Unique identifier for the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the target index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Only perform the operation if the document has this primary term. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs index 035076c71fd..fb066c9c351 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs @@ -22,26 +22,129 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/DeleteScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs index 42659a1f2b2..67d8d48efc2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs @@ -61,6 +61,11 @@ public DeleteScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re { } + [JsonConstructor] + internal DeleteScriptRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceDeleteScript; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -69,6 +74,14 @@ public DeleteScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override string OperationName => "delete_script"; + /// + /// + /// Identifier for the stored script or search template. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs index 660b7f3a641..cf8fe95633a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteScriptResponseConverter))] public sealed partial class DeleteScriptResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Enrich/DeletePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs index 6e2547bbd3c..2bcb065b744 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs @@ -46,6 +46,11 @@ public DeletePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => { } + [JsonConstructor] + internal DeletePolicyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EnrichDeletePolicy; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,14 @@ public DeletePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "enrich.delete_policy"; + + /// + /// + /// Enrich policy to delete. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs index ce4f5649cb9..4a10a689825 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePolicyResponseConverter))] public sealed partial class DeletePolicyResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Enrich/EnrichStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsRequest.g.cs index 83c270e3f05..f70036ec1ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class EnrichStatsRequestParameters : RequestParameters /// public sealed partial class EnrichStatsRequest : PlainRequest { + [JsonConstructor] + internal EnrichStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EnrichStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs index 9e9551fdeb4..6cae3e0690d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propCacheStats = default; + LocalJsonValue> propCoordinatorStats = default; + LocalJsonValue> propExecutingPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCacheStats.TryReadProperty(ref reader, options, PropCacheStats, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCoordinatorStats.TryReadProperty(ref reader, options, PropCoordinatorStats, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propExecutingPolicies.TryReadProperty(ref reader, options, PropExecutingPolicies, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCoordinatorStats, value.CoordinatorStats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExecutingPolicies, value.ExecutingPolicies, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrichStatsResponseConverter))] public sealed partial class EnrichStatsResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,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 +108,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/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs index daa404fd68f..d0fc7805c21 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs @@ -52,6 +52,11 @@ public ExecutePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => { } + [JsonConstructor] + internal ExecutePolicyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EnrichExecutePolicy; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -60,6 +65,14 @@ public ExecutePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override string OperationName => "enrich.execute_policy"; + /// + /// + /// Enrich policy to execute. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, the request blocks other enrich policy execution requests until complete. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs index 16db521cad5..ec5809f0d08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propStatus = default; + LocalJsonValue propTaskId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (propTaskId.TryReadProperty(ref reader, options, PropTaskId, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTaskId, value.TaskId, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecutePolicyResponseConverter))] public sealed partial class ExecutePolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Enrich.ExecuteEnrichPolicyStatus? Status { get; init; } - [JsonInclude, JsonPropertyName("task_id")] public Elastic.Clients.Elasticsearch.TaskId? TaskId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs index 48e5c1b5181..360dfea76b4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs @@ -42,6 +42,7 @@ public sealed partial class GetPolicyRequestParameters : RequestParameters /// public sealed partial class GetPolicyRequest : PlainRequest { + [JsonConstructor] public GetPolicyRequest() { } @@ -57,6 +58,15 @@ public GetPolicyRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r internal override bool SupportsBody => false; internal override string OperationName => "enrich.get_policy"; + + /// + /// + /// Comma-separated list of enrich policy names used to limit the request. + /// To return information for all enrich policies, omit this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs index cadd77f15f8..cb9b5d11584 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicies.TryReadProperty(ref reader, options, PropPolicies, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Enrich/PutPolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs index 7431d4cedbb..39c1320f1af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs @@ -46,6 +46,11 @@ public PutPolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.R { } + [JsonConstructor] + internal PutPolicyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EnrichPutPolicy; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -54,6 +59,14 @@ public PutPolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.R internal override string OperationName => "enrich.put_policy"; + /// + /// + /// Name of the enrich policy to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Matches enrich data to incoming documents based on a geo_shape query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs index b1c1eb5625c..830ed68b771 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPolicyResponseConverter))] public sealed partial class PutPolicyResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Eql/EqlDeleteRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs index ab270a990cd..9f43e900450 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs @@ -47,6 +47,11 @@ public EqlDeleteRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi { } + [JsonConstructor] + internal EqlDeleteRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EqlDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -54,6 +59,16 @@ public EqlDeleteRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override bool SupportsBody => false; internal override string OperationName => "eql.delete"; + + /// + /// + /// Identifier for the search to delete. + /// A search ID is provided in the EQL search API's response for an async search. + /// A search ID is also provided if the request’s keep_on_completion parameter is true. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs index 2ab88cfe2cc..8a3a9f5eea9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EqlDeleteResponseConverter))] public sealed partial class EqlDeleteResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Eql/EqlGetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs index bb6b31ce705..9d0a5606dd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs @@ -61,6 +61,11 @@ public EqlGetRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required { } + [JsonConstructor] + internal EqlGetRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EqlGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -69,6 +74,14 @@ public EqlGetRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required internal override string OperationName => "eql.get"; + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period for which the search and its results are stored on the cluster. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs index ccdd1f5ef9d..5716e5f4b62 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs @@ -22,10 +22,128 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propHits = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue?> propShardFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryReadProperty(ref reader, options, PropHits, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propShardFailures.TryReadProperty(ref reader, options, PropShardFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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 +151,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +158,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +165,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 +172,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 +179,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 +186,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 +193,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/_Generated/Api/Eql/EqlSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs index 5f88564f66a..f44ee9f5698 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs @@ -43,6 +43,204 @@ 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); + LocalJsonValue propAllowPartialSearchResults = default; + LocalJsonValue propAllowPartialSequenceResults = default; + LocalJsonValue propCaseSensitive = default; + LocalJsonValue propEventCategoryField = default; + LocalJsonValue propFetchSize = default; + LocalJsonValue?> propFields = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propKeepAlive = default; + LocalJsonValue propKeepOnCompletion = default; + LocalJsonValue propMaxSamplesPerKey = default; + LocalJsonValue propQuery = default; + LocalJsonValue propResultPosition = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue propTiebreakerField = default; + LocalJsonValue propTimestampField = default; + LocalJsonValue propWaitForCompletionTimeout = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowPartialSearchResults.TryReadProperty(ref reader, options, PropAllowPartialSearchResults, null)) + { + continue; + } + + if (propAllowPartialSequenceResults.TryReadProperty(ref reader, options, PropAllowPartialSequenceResults, null)) + { + continue; + } + + if (propCaseSensitive.TryReadProperty(ref reader, options, PropCaseSensitive, null)) + { + continue; + } + + if (propEventCategoryField.TryReadProperty(ref reader, options, PropEventCategoryField, null)) + { + continue; + } + + if (propFetchSize.TryReadProperty(ref reader, options, PropFetchSize, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propKeepAlive.TryReadProperty(ref reader, options, PropKeepAlive, null)) + { + continue; + } + + if (propKeepOnCompletion.TryReadProperty(ref reader, options, PropKeepOnCompletion, null)) + { + continue; + } + + if (propMaxSamplesPerKey.TryReadProperty(ref reader, options, PropMaxSamplesPerKey, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propResultPosition.TryReadProperty(ref reader, options, PropResultPosition, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propTiebreakerField.TryReadProperty(ref reader, options, PropTiebreakerField, null)) + { + continue; + } + + if (propTimestampField.TryReadProperty(ref reader, options, PropTimestampField, null)) + { + continue; + } + + if (propWaitForCompletionTimeout.TryReadProperty(ref reader, options, PropWaitForCompletionTimeout, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAllowPartialSequenceResults, value.AllowPartialSequenceResults, null, null); + writer.WriteProperty(options, PropCaseSensitive, value.CaseSensitive, null, null); + writer.WriteProperty(options, PropEventCategoryField, value.EventCategoryField, null, null); + writer.WriteProperty(options, PropFetchSize, value.FetchSize, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropKeepAlive, value.KeepAlive, null, null); + writer.WriteProperty(options, PropKeepOnCompletion, value.KeepOnCompletion, null, null); + writer.WriteProperty(options, PropMaxSamplesPerKey, value.MaxSamplesPerKey, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropResultPosition, value.ResultPosition, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropTiebreakerField, value.TiebreakerField, null, null); + writer.WriteProperty(options, PropTimestampField, value.TimestampField, null, null); + writer.WriteProperty(options, PropWaitForCompletionTimeout, value.WaitForCompletionTimeout, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Get EQL search results. @@ -50,12 +248,18 @@ 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.Indices indices) : base(r => r.Required("index", indices)) { } + [JsonConstructor] + internal EqlSearchRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EqlSearch; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -64,9 +268,13 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "eql.search"; - [JsonIgnore] + /// + /// + /// The name of the index to scope the operation + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } 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 +282,9 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// 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 +292,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field containing the event classification, such as process, file, or network. /// /// - [JsonInclude, JsonPropertyName("event_category_field")] public Elastic.Clients.Elasticsearch.Field? EventCategoryField { get; set; } /// @@ -96,7 +299,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Maximum number of events to search at a time for sequence queries. /// /// - [JsonInclude, JsonPropertyName("fetch_size")] public int? FetchSize { get; set; } /// @@ -104,8 +306,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// 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.QueryDsl.FieldAndFormat))] public ICollection? Fields { get; set; } /// @@ -113,12 +313,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Query, written in Query DSL, used to filter the events on which the EQL query runs. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } - [JsonInclude, JsonPropertyName("keep_alive")] public Elastic.Clients.Elasticsearch.Duration? KeepAlive { get; set; } - [JsonInclude, JsonPropertyName("keep_on_completion")] public bool? KeepOnCompletion { get; set; } /// @@ -128,7 +324,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// 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 +331,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// EQL query you wish to run. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("result_position")] public Elastic.Clients.Elasticsearch.Eql.ResultPosition? ResultPosition { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -148,7 +340,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// For basic queries, the maximum number of matching events to return. Defaults to 10 /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -156,7 +347,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field used to sort hits with the same timestamp in ascending order /// /// - [JsonInclude, JsonPropertyName("tiebreaker_field")] public Elastic.Clients.Elasticsearch.Field? TiebreakerField { get; set; } /// @@ -164,9 +354,7 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field containing event timestamp. Default "@timestamp" /// /// - [JsonInclude, JsonPropertyName("timestamp_field")] public Elastic.Clients.Elasticsearch.Field? TimestampField { get; set; } - [JsonInclude, JsonPropertyName("wait_for_completion_timeout")] public Elastic.Clients.Elasticsearch.Duration? WaitForCompletionTimeout { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs index 720dbc35012..f9f1d04d40f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs @@ -22,10 +22,128 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propHits = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue?> propShardFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryReadProperty(ref reader, options, PropHits, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propShardFailures.TryReadProperty(ref reader, options, PropShardFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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 +151,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +158,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +165,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 +172,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 +179,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 +186,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 +193,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/_Generated/Api/Eql/GetEqlStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs index faba4187dbb..c23fb1dc3e6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs @@ -46,6 +46,11 @@ public GetEqlStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re { } + [JsonConstructor] + internal GetEqlStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EqlGetStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,14 @@ public GetEqlStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override bool SupportsBody => false; internal override string OperationName => "eql.get_status"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs index a087b94c3a8..3f056c6e2cc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs @@ -22,10 +22,101 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryReadProperty(ref reader, options, PropCompletionStatus, null)) + { + continue; + } + + if (propExpirationTimeInMillis.TryReadProperty(ref reader, options, PropExpirationTimeInMillis, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetEqlStatusResponseConverter))] public sealed partial class GetEqlStatusResponse : ElasticsearchResponse { /// @@ -33,7 +124,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 +131,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 +138,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -57,7 +145,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 +152,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 +159,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/_Generated/Api/Esql/EsqlQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Esql/EsqlQueryRequest.g.cs index 1947cab2686..c74d80b4ce4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Esql/EsqlQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Esql/EsqlQueryRequest.g.cs @@ -63,6 +63,11 @@ public sealed partial class EsqlQueryRequestParameters : RequestParameters /// public sealed partial class EsqlQueryRequest : PlainRequest { + [JsonConstructor] + internal EsqlQueryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.EsqlQuery; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs index a69f181062f..96a7446c2f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs @@ -119,6 +119,11 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie { } + [JsonConstructor] + internal ExistsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceExists; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -127,6 +132,23 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "exists"; + /// + /// + /// Identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs index 92ee29cc3a7..bdc8bad8140 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs @@ -110,6 +110,11 @@ public ExistsSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elasti { } + [JsonConstructor] + internal ExistsSourceRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceExistsSource; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -118,6 +123,23 @@ public ExistsSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elasti internal override string OperationName => "exists_source"; + /// + /// + /// Identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs index a747706a688..f16092c9e35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs @@ -131,6 +131,11 @@ public ExplainRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Cli { } + [JsonConstructor] + internal ExplainRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceExplain; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -139,6 +144,23 @@ public ExplainRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Cli internal override string OperationName => "explain"; + /// + /// + /// Defines the document ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Index names used to limit the request. + /// Only a single index name can be provided to this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Analyzer to use for the query string. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs index 507b277bdfe..cf18bc89bc0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs @@ -22,20 +22,113 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propExplanation = default; + LocalJsonValue?> propGet = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMatched = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryReadProperty(ref reader, options, PropExplanation, null)) + { + continue; + } + + if (propGet.TryReadProperty(ref reader, options, PropGet, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMatched.TryReadProperty(ref reader, options, PropMatched, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropGet, value.Get, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMatched, value.Matched, null, null); + 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.Core.Explain.ExplanationDetail? Explanation { get; init; } - [JsonInclude, JsonPropertyName("get")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Features/GetFeaturesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesRequest.g.cs index ec3b39f037f..db911254f2a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesRequest.g.cs @@ -52,6 +52,11 @@ public sealed partial class GetFeaturesRequestParameters : RequestParameters /// public sealed partial class GetFeaturesRequest : PlainRequest { + [JsonConstructor] + internal GetFeaturesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.FeaturesGetFeatures; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs index 330a44bf3e4..a0ca97bb824 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Features; +internal sealed partial class GetFeaturesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + + public override GetFeaturesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFeatures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatures.TryReadProperty(ref reader, options, PropFeatures, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetFeaturesResponse + { + Features = propFeatures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetFeaturesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatures, value.Features, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetFeaturesResponseConverter))] public sealed partial class GetFeaturesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("features")] public IReadOnlyCollection Features { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesRequest.g.cs index 5a4891114bd..b4c92549c8e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesRequest.g.cs @@ -63,6 +63,11 @@ public sealed partial class ResetFeaturesRequestParameters : RequestParameters /// public sealed partial class ResetFeaturesRequest : PlainRequest { + [JsonConstructor] + internal ResetFeaturesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.FeaturesResetFeatures; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs index d92067d295e..d0477b2d4b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Features; +internal sealed partial class ResetFeaturesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + + public override ResetFeaturesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFeatures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatures.TryReadProperty(ref reader, options, PropFeatures, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetFeaturesResponse + { + Features = propFeatures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetFeaturesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatures, value.Features, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetFeaturesResponseConverter))] public sealed partial class ResetFeaturesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("features")] public IReadOnlyCollection Features { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs index 40ca0aa9140..91ad899b55b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs @@ -84,6 +84,64 @@ 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); + LocalJsonValue propFields = default; + LocalJsonValue propIndexFilter = default; + LocalJsonValue?> propRuntimeMappings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propIndexFilter.TryReadProperty(ref reader, options, PropIndexFilter, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropIndexFilter, value.IndexFilter, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + /// /// /// Get the field capabilities. @@ -97,8 +155,10 @@ 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 { + [JsonConstructor] public FieldCapsRequest() { } @@ -115,6 +175,13 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "field_caps"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, @@ -122,7 +189,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +196,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +203,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +210,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +217,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +224,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// If true, unmapped fields are included in the response. /// /// - [JsonIgnore] public bool? IncludeUnmapped { get => Q("include_unmapped"); set => Q("include_unmapped", value); } /// @@ -170,7 +231,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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 +238,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// List of fields to retrieve capabilities for. Wildcard (*) expressions are supported. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -187,7 +245,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// Allows to filter indices if the provided query rewrites to match_none on every shard. /// /// - [JsonInclude, JsonPropertyName("index_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilter { get; set; } /// @@ -196,7 +253,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// 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/_Generated/Api/FieldCapsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs index 1f2841fe397..62505a72419 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs @@ -22,16 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue>> propFields = default; + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)!)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary> v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + 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/_Generated/Api/GetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs index e71f67d6fca..8d0b38f80f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs @@ -126,6 +126,11 @@ public GetRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients { } + [JsonConstructor] + internal GetRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -134,6 +139,22 @@ public GetRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients internal override string OperationName => "get"; + /// + /// + /// Unique identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Should this request force synthetic _source? diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs index 09773e266f6..69a38c2e073 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs @@ -22,31 +22,168 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIgnored.TryReadProperty(ref reader, options, PropIgnored, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFound, value.Found, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIgnored, value.Ignored, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.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/_Generated/Api/GetScriptContextRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextRequest.g.cs index 4364f3b5fe8..df043061cda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class GetScriptContextRequestParameters : RequestParameter /// public sealed partial class GetScriptContextRequest : PlainRequest { + [JsonConstructor] + internal GetScriptContextRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceGetScriptContext; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs index 675104dff9c..beffca1b734 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetScriptContextResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + + public override GetScriptContextResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propContexts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propContexts.TryReadProperty(ref reader, options, PropContexts, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptContextResponse + { + Contexts = propContexts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptContextResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropContexts, value.Contexts, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptContextResponseConverter))] public sealed partial class GetScriptContextResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("contexts")] public IReadOnlyCollection Contexts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesRequest.g.cs index eb6c1779d1b..5a5651b6af4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class GetScriptLanguagesRequestParameters : RequestParamet /// public sealed partial class GetScriptLanguagesRequest : PlainRequest { + [JsonConstructor] + internal GetScriptLanguagesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceGetScriptLanguages; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs index 37a210be29b..a04599eccd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetScriptLanguagesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguageContexts = System.Text.Json.JsonEncodedText.Encode("language_contexts"); + private static readonly System.Text.Json.JsonEncodedText PropTypesAllowed = System.Text.Json.JsonEncodedText.Encode("types_allowed"); + + public override GetScriptLanguagesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propLanguageContexts = default; + LocalJsonValue> propTypesAllowed = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguageContexts.TryReadProperty(ref reader, options, PropLanguageContexts, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTypesAllowed.TryReadProperty(ref reader, options, PropTypesAllowed, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptLanguagesResponse + { + LanguageContexts = propLanguageContexts.Value +, + TypesAllowed = propTypesAllowed.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptLanguagesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguageContexts, value.LanguageContexts, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTypesAllowed, value.TypesAllowed, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptLanguagesResponseConverter))] public sealed partial class GetScriptLanguagesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("language_contexts")] public IReadOnlyCollection LanguageContexts { get; init; } - [JsonInclude, JsonPropertyName("types_allowed")] public IReadOnlyCollection TypesAllowed { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs index 27db2736d08..dedcb103a2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs @@ -52,6 +52,11 @@ public GetScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi { } + [JsonConstructor] + internal GetScriptRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceGetScript; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -60,6 +65,14 @@ public GetScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override string OperationName => "get_script"; + /// + /// + /// Identifier for the stored script or search template. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specify timeout for connection to master diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs index e9e8fa8c010..56a6ef2d083 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + 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.StoredScript? Script { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs index d44b4d6b1a2..aece2f78235 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs @@ -109,6 +109,11 @@ public GetSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.C { } + [JsonConstructor] + internal GetSourceRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceGetSource; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -117,6 +122,22 @@ public GetSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.C internal override string OperationName => "get_source"; + /// + /// + /// Unique identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. Random by default. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs index 9a575d572f9..6521b34c384 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs @@ -65,6 +65,11 @@ public ExploreRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => { } + [JsonConstructor] + internal ExploreRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.GraphExplore; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -73,6 +78,14 @@ public ExploreRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => internal override string OperationName => "graph.explore"; + /// + /// + /// Name of the index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// Custom value used to route operations to a specific shard. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs index b916b224e45..8703c2795e5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propConnections = default; + LocalJsonValue> propFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue> propVertices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propConnections.TryReadProperty(ref reader, options, PropConnections, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propFailures.TryReadProperty(ref reader, options, PropFailures, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propVertices.TryReadProperty(ref reader, options, PropVertices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFailures, value.Failures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropVertices, value.Vertices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/HealthReportRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs index 1e319f394cf..e3640e9ba6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs @@ -83,6 +83,7 @@ public sealed partial class HealthReportRequestParameters : RequestParameters /// public sealed partial class HealthReportRequest : PlainRequest { + [JsonConstructor] public HealthReportRequest() { } @@ -99,6 +100,14 @@ public HealthReportRequest(IReadOnlyCollection? feature) : base(r => r.O internal override string OperationName => "health_report"; + /// + /// + /// A feature of the cluster, as returned by the top-level health report API. + /// + /// + [JsonIgnore] + public ICollection? Feature { get => P?>("feature"); set => PO("feature", value); } + /// /// /// Limit the number of affected resources the health report API returns. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs index a076c3eba52..13f31d37888 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propClusterName = default; + LocalJsonValue propIndicators = default; + LocalJsonValue propStatus = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propIndicators.TryReadProperty(ref reader, options, PropIndicators, null)) + { + continue; + } + + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropIndicators, value.Indicators, null, null); + writer.WriteProperty(options, PropStatus, value.Status, null, null); + 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.Core.HealthReport.Indicators Indicators { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Core.HealthReport.IndicatorHealthStatus? Status { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs index aac721e8e18..bf8095c9894 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs @@ -59,6 +59,11 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r { } + [JsonConstructor] + internal DeleteLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementDeleteLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -67,6 +72,14 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "ilm.delete_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("policy"); set => PR("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs index 07ce56d24ab..d5f32a3225a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLifecycleResponseConverter))] public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexLifecycleManagement/GetIlmStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusRequest.g.cs index 7ca469ce9c7..1244b2a4b31 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class GetIlmStatusRequestParameters : RequestParameters /// public sealed partial class GetIlmStatusRequest : PlainRequest { + [JsonConstructor] + internal GetIlmStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementGetStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs index 0cb87d29c09..a72232367a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class GetIlmStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOperationMode = System.Text.Json.JsonEncodedText.Encode("operation_mode"); + + public override GetIlmStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propOperationMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOperationMode.TryReadProperty(ref reader, options, PropOperationMode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIlmStatusResponse + { + OperationMode = propOperationMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIlmStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOperationMode, value.OperationMode, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIlmStatusResponseConverter))] public sealed partial class GetIlmStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("operation_mode")] public Elastic.Clients.Elasticsearch.LifecycleOperationMode OperationMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs index c2d33b459fc..bc8bf56ac22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs @@ -54,6 +54,7 @@ public sealed partial class GetLifecycleRequestParameters : RequestParameters /// public sealed partial class GetLifecycleRequest : PlainRequest { + [JsonConstructor] public GetLifecycleRequest() { } @@ -70,6 +71,14 @@ public GetLifecycleRequest(Elastic.Clients.Elasticsearch.Name? name) : base(r => internal override string OperationName => "ilm.get_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("policy"); set => PO("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersRequest.g.cs index 111adb650af..91e1737126e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersRequest.g.cs @@ -76,6 +76,11 @@ public sealed partial class MigrateToDataTiersRequestParameters : RequestParamet /// public sealed partial class MigrateToDataTiersRequest : PlainRequest { + [JsonConstructor] + internal MigrateToDataTiersRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMigrateToDataTiers; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs index d0d38a0096a..9f47d21323a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs @@ -22,25 +22,118 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class MigrateToDataTiersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDryRun = System.Text.Json.JsonEncodedText.Encode("dry_run"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedComponentTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_component_templates"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedComposableTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_composable_templates"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedIlmPolicies = System.Text.Json.JsonEncodedText.Encode("migrated_ilm_policies"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedIndices = System.Text.Json.JsonEncodedText.Encode("migrated_indices"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedLegacyTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_legacy_templates"); + private static readonly System.Text.Json.JsonEncodedText PropRemovedLegacyTemplate = System.Text.Json.JsonEncodedText.Encode("removed_legacy_template"); + + public override MigrateToDataTiersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDryRun = default; + LocalJsonValue> propMigratedComponentTemplates = default; + LocalJsonValue> propMigratedComposableTemplates = default; + LocalJsonValue> propMigratedIlmPolicies = default; + LocalJsonValue> propMigratedIndices = default; + LocalJsonValue> propMigratedLegacyTemplates = default; + LocalJsonValue propRemovedLegacyTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDryRun.TryReadProperty(ref reader, options, PropDryRun, null)) + { + continue; + } + + if (propMigratedComponentTemplates.TryReadProperty(ref reader, options, PropMigratedComponentTemplates, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propMigratedComposableTemplates.TryReadProperty(ref reader, options, PropMigratedComposableTemplates, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propMigratedIlmPolicies.TryReadProperty(ref reader, options, PropMigratedIlmPolicies, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propMigratedIndices.TryReadProperty(ref reader, options, PropMigratedIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propMigratedLegacyTemplates.TryReadProperty(ref reader, options, PropMigratedLegacyTemplates, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propRemovedLegacyTemplate.TryReadProperty(ref reader, options, PropRemovedLegacyTemplate, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MigrateToDataTiersResponse + { + DryRun = propDryRun.Value +, + MigratedComponentTemplates = propMigratedComponentTemplates.Value +, + MigratedComposableTemplates = propMigratedComposableTemplates.Value +, + MigratedIlmPolicies = propMigratedIlmPolicies.Value +, + MigratedIndices = propMigratedIndices.Value +, + MigratedLegacyTemplates = propMigratedLegacyTemplates.Value +, + RemovedLegacyTemplate = propRemovedLegacyTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MigrateToDataTiersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDryRun, value.DryRun, null, null); + writer.WriteProperty(options, PropMigratedComponentTemplates, value.MigratedComponentTemplates, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMigratedComposableTemplates, value.MigratedComposableTemplates, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMigratedIlmPolicies, value.MigratedIlmPolicies, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMigratedIndices, value.MigratedIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMigratedLegacyTemplates, value.MigratedLegacyTemplates, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRemovedLegacyTemplate, value.RemovedLegacyTemplate, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MigrateToDataTiersResponseConverter))] public sealed partial class MigrateToDataTiersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("dry_run")] public bool DryRun { get; init; } - [JsonInclude, JsonPropertyName("migrated_component_templates")] public IReadOnlyCollection MigratedComponentTemplates { get; init; } - [JsonInclude, JsonPropertyName("migrated_composable_templates")] public IReadOnlyCollection MigratedComposableTemplates { get; init; } - [JsonInclude, JsonPropertyName("migrated_ilm_policies")] public IReadOnlyCollection MigratedIlmPolicies { get; init; } - [JsonInclude, JsonPropertyName("migrated_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection MigratedIndices { get; init; } - [JsonInclude, JsonPropertyName("migrated_legacy_templates")] public IReadOnlyCollection MigratedLegacyTemplates { get; init; } - [JsonInclude, JsonPropertyName("removed_legacy_template")] public string RemovedLegacyTemplate { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs index e69e5d40c39..8cf37eabc39 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs @@ -61,6 +61,11 @@ public MoveToStepRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r { } + [JsonConstructor] + internal MoveToStepRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMoveToStep; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -69,6 +74,13 @@ public MoveToStepRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r internal override string OperationName => "ilm.move_to_step"; + /// + /// + /// The name of the index whose lifecycle step is to change + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("current_step")] public Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey CurrentStep { get; set; } [JsonInclude, JsonPropertyName("next_step")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs index 081d908885b..1a28ffa30b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class MoveToStepResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override MoveToStepResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MoveToStepResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MoveToStepResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MoveToStepResponseConverter))] public sealed partial class MoveToStepResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class MoveToStepResponse : 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/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs index 3b17d1e0c82..823c662b2dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs @@ -62,6 +62,11 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => { } + [JsonConstructor] + internal PutLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementPutLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -70,6 +75,14 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override string OperationName => "ilm.put_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("policy"); set => PR("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs index d9f92f43a06..0ea32e21525 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutLifecycleResponseConverter))] public sealed partial class PutLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs index 9c0c9c4438b..5449facd12f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs @@ -47,6 +47,11 @@ public RemovePolicyRequest(Elastic.Clients.Elasticsearch.IndexName index) : base { } + [JsonConstructor] + internal RemovePolicyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementRemovePolicy; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,14 @@ public RemovePolicyRequest(Elastic.Clients.Elasticsearch.IndexName index) : base internal override bool SupportsBody => false; internal override string OperationName => "ilm.remove_policy"; + + /// + /// + /// The name of the index to remove policy on + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs index 2b40e8f3b60..bdb9022a61a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class RemovePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFailedIndexes = System.Text.Json.JsonEncodedText.Encode("failed_indexes"); + private static readonly System.Text.Json.JsonEncodedText PropHasFailures = System.Text.Json.JsonEncodedText.Encode("has_failures"); + + public override RemovePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFailedIndexes = default; + LocalJsonValue propHasFailures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFailedIndexes.TryReadProperty(ref reader, options, PropFailedIndexes, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propHasFailures.TryReadProperty(ref reader, options, PropHasFailures, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemovePolicyResponse + { + FailedIndexes = propFailedIndexes.Value +, + HasFailures = propHasFailures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemovePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFailedIndexes, value.FailedIndexes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropHasFailures, value.HasFailures, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemovePolicyResponseConverter))] public sealed partial class RemovePolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("failed_indexes")] public IReadOnlyCollection FailedIndexes { get; init; } - [JsonInclude, JsonPropertyName("has_failures")] public bool HasFailures { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs index 7ffff1bb01e..088e3e09c64 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs @@ -48,6 +48,11 @@ public RetryRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r { } + [JsonConstructor] + internal RetryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementRetry; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -55,6 +60,14 @@ public RetryRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r internal override bool SupportsBody => false; internal override string OperationName => "ilm.retry"; + + /// + /// + /// The name of the indices (comma-separated) whose failed lifecycle step is to be retry + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs index 73e6389fe10..d3726ec4d37 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class RetryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override RetryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RetryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RetryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RetryResponseConverter))] public sealed partial class RetryResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class RetryResponse : 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/_Generated/Api/IndexLifecycleManagement/StartIlmRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmRequest.g.cs index 9458140d79e..d579d0b71fb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmRequest.g.cs @@ -46,6 +46,11 @@ public sealed partial class StartIlmRequestParameters : RequestParameters /// public sealed partial class StartIlmRequest : PlainRequest { + [JsonConstructor] + internal StartIlmRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementStart; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs index 039eca5b3fc..ead9c94b94d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class StartIlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartIlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartIlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartIlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartIlmResponseConverter))] public sealed partial class StartIlmResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class StartIlmResponse : 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/_Generated/Api/IndexLifecycleManagement/StopIlmRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmRequest.g.cs index 900918996e5..ef3fb6f012c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmRequest.g.cs @@ -49,6 +49,11 @@ public sealed partial class StopIlmRequestParameters : RequestParameters /// public sealed partial class StopIlmRequest : PlainRequest { + [JsonConstructor] + internal StopIlmRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementStop; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs index d41403aec0b..0088b5d6c2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class StopIlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopIlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopIlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopIlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopIlmResponseConverter))] public sealed partial class StopIlmResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class StopIlmResponse : 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/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs index 0a17e30d21c..32e072b7adc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs @@ -34,14 +34,134 @@ 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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue?> propAttributes = default; + LocalJsonValue?> propCharFilter = default; + LocalJsonValue propExplain = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propNormalizer = default; + LocalJsonValue?> propText = default; + LocalJsonValue propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propAttributes.TryReadProperty(ref reader, options, PropAttributes, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCharFilter.TryReadProperty(ref reader, options, PropCharFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNormalizer.TryReadProperty(ref reader, options, PropNormalizer, null)) + { + continue; + } + + if (propText.TryReadProperty(ref reader, options, PropText, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propTokenizer.TryReadProperty(ref reader, options, PropTokenizer, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAttributes, value.Attributes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCharFilter, value.CharFilter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNormalizer, value.Normalizer, null, null); + writer.WriteProperty(options, PropText, value.Text, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Get tokens from text analysis. /// The analyze API performs analysis on a text string and returns the resulting tokens. /// /// +[JsonConverter(typeof(AnalyzeIndexRequestConverter))] public sealed partial class AnalyzeIndexRequest : PlainRequest { + [JsonConstructor] public AnalyzeIndexRequest() { } @@ -58,13 +178,21 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas internal override string OperationName => "indices.analyze"; + /// + /// + /// Index used to derive the analyzer. + /// If specified, the analyzer or field parameter overrides this value. + /// If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// The name of the analyzer that should be applied to the provided text. /// 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; } /// @@ -72,7 +200,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of token attributes used to filter the output of the explain parameter. /// /// - [JsonInclude, JsonPropertyName("attributes")] public ICollection? Attributes { get; set; } /// @@ -80,7 +207,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of character filters used to preprocess characters before the tokenizer. /// /// - [JsonInclude, JsonPropertyName("char_filter")] public ICollection? CharFilter { get; set; } /// @@ -88,7 +214,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// If true, the response includes token attributes and additional details. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -98,7 +223,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// If specified, the analyzer parameter overrides this value. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -106,7 +230,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of token filters used to apply after the tokenizer. /// /// - [JsonInclude, JsonPropertyName("filter")] public ICollection? Filter { get; set; } /// @@ -114,7 +237,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Normalizer to use to convert text into a single token. /// /// - [JsonInclude, JsonPropertyName("normalizer")] public string? Normalizer { get; set; } /// @@ -123,8 +245,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// 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; } /// @@ -132,7 +252,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Tokenizer to use to convert text into tokens. /// /// - [JsonInclude, JsonPropertyName("tokenizer")] public Elastic.Clients.Elasticsearch.Analysis.ITokenizer? Tokenizer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs index 13b4f7e9f3a..a757a11fb83 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDetail = default; + LocalJsonValue?> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetail.TryReadProperty(ref reader, options, PropDetail, null)) + { + continue; + } + + if (propTokens.TryReadProperty(ref reader, options, PropTokens, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTokens, value.Tokens, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AnalyzeIndexResponseConverter))] public sealed partial class AnalyzeIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("detail")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs index 86ff0cc74bc..6a286127f1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs @@ -96,6 +96,7 @@ public sealed partial class ClearCacheRequestParameters : RequestParameters /// public sealed partial class ClearCacheRequest : PlainRequest { + [JsonConstructor] public ClearCacheRequest() { } @@ -112,6 +113,16 @@ public ClearCacheRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.clear_cache"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs index 889431a5852..d6d604d241a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCacheResponseConverter))] public sealed partial class ClearCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs index e6c9e2e8529..06aec5b10fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs @@ -120,6 +120,11 @@ public CloneIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. { } + [JsonConstructor] + internal CloneIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementClone; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -128,6 +133,22 @@ public CloneIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.clone"; + /// + /// + /// Name of the source index to clone. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs index e4a02be3cea..2c932f6b293 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class CloneIndexResponseConverter : 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 CloneIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloneIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloneIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloneIndexResponseConverter))] public sealed partial class CloneIndexResponse : 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/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs index e531c9a51b4..2d6f22d39bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs @@ -114,6 +114,11 @@ public CloseIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r { } + [JsonConstructor] + internal CloseIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementClose; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -122,6 +127,14 @@ public CloseIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.close"; + /// + /// + /// Comma-separated list or wildcard expression of index names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs index 388a41401eb..1835e594392 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs @@ -22,17 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + 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.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/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs index 1c318a40ef9..f97e5947f0b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs @@ -60,6 +60,11 @@ public CreateDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamName name { } + [JsonConstructor] + internal CreateDataStreamRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementCreateDataStream; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -68,6 +73,19 @@ public CreateDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamName name internal override string OperationName => "indices.create_data_stream"; + /// + /// + /// Name of the data stream, which must meet the following criteria: + /// Lowercase only; + /// Cannot include \, /, *, ?, ", <, >, |, ,, #, :, or a space character; + /// Cannot start with -, _, +, or .ds-; + /// Cannot be . or ..; + /// Cannot be longer than 255 bytes. Multi-byte characters count towards this limit faster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs index 8317bdb2da9..cfb42eb8a0f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateDataStreamResponseConverter))] public sealed partial class CreateDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs index 1cab06ad5e6..7e26b39baa9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs @@ -69,6 +69,11 @@ public CreateIndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( { } + [JsonConstructor] + internal CreateIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementCreate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -77,6 +82,14 @@ public CreateIndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override string OperationName => "indices.create"; + /// + /// + /// Name of the index you wish to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs index 8a847b2e204..a61529eb867 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + 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/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs index 91a722ceab5..001ed98e930 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs @@ -49,6 +49,7 @@ public sealed partial class DataStreamsStatsRequestParameters : RequestParameter /// public sealed partial class DataStreamsStatsRequest : PlainRequest { + [JsonConstructor] public DataStreamsStatsRequest() { } @@ -65,6 +66,16 @@ public DataStreamsStatsRequest(Elastic.Clients.Elasticsearch.IndexName? name) : internal override string OperationName => "indices.data_streams_stats"; + /// + /// + /// Comma-separated list of data streams used to limit the request. + /// Wildcard expressions (*) are supported. + /// To target all data streams in a cluster, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Name { get => P("name"); set => PO("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs index e4b9e962207..d79270fd89d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs @@ -22,10 +22,101 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBackingIndices = default; + LocalJsonValue propDataStreamCount = default; + LocalJsonValue> propDataStreams = default; + LocalJsonValue propShards = default; + LocalJsonValue propTotalStoreSizeBytes = default; + LocalJsonValue propTotalStoreSizes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryReadProperty(ref reader, options, PropBackingIndices, null)) + { + continue; + } + + if (propDataStreamCount.TryReadProperty(ref reader, options, PropDataStreamCount, null)) + { + continue; + } + + if (propDataStreams.TryReadProperty(ref reader, options, PropDataStreams, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propTotalStoreSizeBytes.TryReadProperty(ref reader, options, PropTotalStoreSizeBytes, null)) + { + continue; + } + + if (propTotalStoreSizes.TryReadProperty(ref reader, options, PropTotalStoreSizes, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDataStreamCount, value.DataStreamCount, null, null); + writer.WriteProperty(options, PropDataStreams, value.DataStreams, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropTotalStoreSizeBytes, value.TotalStoreSizeBytes, null, null); + writer.WriteProperty(options, PropTotalStoreSizes, value.TotalStoreSizes, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataStreamsStatsResponseConverter))] public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +124,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 +131,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 +138,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 +145,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Contains information about shards that attempted to execute the request. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } /// @@ -65,7 +152,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 +160,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.ByteSize? TotalStoreSizes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs index 588bc1ad8f5..6fa1b62d06b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs @@ -61,6 +61,11 @@ public DeleteAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic { } + [JsonConstructor] + internal DeleteAliasRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDeleteAlias; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -69,6 +74,24 @@ public DeleteAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic internal override string OperationName => "indices.delete_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// Comma-separated list of aliases to remove. + /// Supports wildcards (*). To remove all aliases, use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs index ae5ec7e2278..bfa61b76cd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAliasResponseConverter))] public sealed partial class DeleteAliasResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs index 0a961381c9e..c4e8fe933fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs @@ -66,6 +66,11 @@ public DeleteDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames { } + [JsonConstructor] + internal DeleteDataLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDeleteDataLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -74,6 +79,14 @@ public DeleteDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames internal override string OperationName => "indices.delete_data_lifecycle"; + /// + /// + /// A comma-separated list of data streams of which the data stream lifecycle will be deleted; use * to get all data streams + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Whether wildcard expressions should get expanded to open or closed indices (default: open) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs index f9d2038fc50..f775e72e90d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataLifecycleResponseConverter))] public sealed partial class DeleteDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs index 80fccc1863f..53de12434a6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs @@ -59,6 +59,11 @@ public DeleteDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam { } + [JsonConstructor] + internal DeleteDataStreamRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDeleteDataStream; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -67,6 +72,14 @@ public DeleteDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.delete_data_stream"; + /// + /// + /// Comma-separated list of data streams to delete. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. Supports comma-separated values,such as open,hidden. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs index fbecc62a90f..78ae52d871d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataStreamResponseConverter))] public sealed partial class DeleteDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs index f73c4862ff4..60d7ca5dc51 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs @@ -86,6 +86,11 @@ public DeleteIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( { } + [JsonConstructor] + internal DeleteIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -94,6 +99,17 @@ public DeleteIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( internal override string OperationName => "indices.delete"; + /// + /// + /// Comma-separated list of indices to delete. + /// You cannot specify index aliases. + /// By default, this parameter does not support wildcards (*) or _all. + /// To use wildcards or _all, set the action.destructive_requires_name cluster setting to false. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs index 1462583eece..6fc77fe9fdf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexResponseConverter))] public sealed partial class DeleteIndexResponse : ElasticsearchResponse { /// @@ -33,8 +84,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.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs index 196e97ac096..f662f201719 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs @@ -61,6 +61,11 @@ public DeleteIndexTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : ba { } + [JsonConstructor] + internal DeleteIndexTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDeleteIndexTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -69,6 +74,14 @@ public DeleteIndexTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : ba internal override string OperationName => "indices.delete_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs index b80c8280abb..11e4bd96a6d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexTemplateResponseConverter))] public sealed partial class DeleteIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs index 22c27dca5fb..7f484c17755 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs @@ -60,6 +60,11 @@ public DeleteTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = { } + [JsonConstructor] + internal DeleteTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDeleteTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -68,6 +73,15 @@ public DeleteTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = internal override string OperationName => "indices.delete_template"; + /// + /// + /// The name of the legacy index template to delete. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs index a4129c54a7c..26105856c65 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTemplateResponseConverter))] public sealed partial class DeleteTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class DeleteTemplateResponse : 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/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs index f72d916026c..efa50727761 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs @@ -88,6 +88,11 @@ public DiskUsageRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r { } + [JsonConstructor] + internal DiskUsageRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDiskUsage; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -96,6 +101,15 @@ public DiskUsageRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.disk_usage"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// It’s recommended to execute this API with a single index (or the latest backing index of a data stream) as the API consumes resources significantly. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs index 0685bdc4ac9..d63fd41c45e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs @@ -34,6 +34,19 @@ public sealed partial class DownsampleRequestParameters : RequestParameters { } +internal sealed partial class DownsampleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override DownsampleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new DownsampleRequest { Config = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DownsampleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Config, null); + } +} + /// /// /// Downsample an index. @@ -47,12 +60,18 @@ public sealed partial class DownsampleRequestParameters : RequestParameters /// The source index must be read only (index.blocks.write: true). /// /// -public sealed partial class DownsampleRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(DownsampleRequestConverter))] +public sealed partial class DownsampleRequest : PlainRequest { public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.IndexName targetIndex) : base(r => r.Required("index", index).Required("target_index", targetIndex)) { } + [JsonConstructor] + internal DownsampleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementDownsample; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -61,13 +80,20 @@ public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.downsample"; - [JsonIgnore] + /// + /// + /// Name of the time series index to downsample. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the index to create. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName TargetIndex { get => P("target_index"); set => PR("target_index", value); } public Elastic.Clients.Elasticsearch.IndexManagement.DownsampleConfig Config { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Config, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs index ee84ea82590..ad55b1c3e36 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs @@ -82,6 +82,11 @@ public ExistsAliasRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elasti { } + [JsonConstructor] + internal ExistsAliasRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementExistsAlias; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -90,6 +95,23 @@ public ExistsAliasRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elasti internal override string OperationName => "indices.exists_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list of aliases to check. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs index 0fafea15669..c093f54a90f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs @@ -52,6 +52,11 @@ public ExistsIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : bas { } + [JsonConstructor] + internal ExistsIndexTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementExistsIndexTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -60,6 +65,14 @@ public ExistsIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : bas internal override string OperationName => "indices.exists_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs index efbc7dff46a..452b173b768 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs @@ -91,6 +91,11 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => { } + [JsonConstructor] + internal ExistsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementExists; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -99,6 +104,14 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => internal override string OperationName => "indices.exists"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs index 59042066550..815645024bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs @@ -66,6 +66,11 @@ public ExistsTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : base(r { } + [JsonConstructor] + internal ExistsTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementExistsTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; @@ -74,6 +79,14 @@ public ExistsTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : base(r internal override string OperationName => "indices.exists_template"; + /// + /// + /// The comma separated names of the index templates + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Return settings in flat format (default: false) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs index 5eab5eca85d..36680c8d1c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs @@ -59,6 +59,11 @@ public ExplainDataLifecycleRequest(Elastic.Clients.Elasticsearch.Indices indices { } + [JsonConstructor] + internal ExplainDataLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementExplainDataLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -67,6 +72,14 @@ public ExplainDataLifecycleRequest(Elastic.Clients.Elasticsearch.Indices indices internal override string OperationName => "indices.explain_data_lifecycle"; + /// + /// + /// The name of the index to explain + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// indicates if the API should return the default values the system uses for the index's lifecycle diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs index 8dfd1f29eeb..7e437986afa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs @@ -22,13 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataLifecycleResponseConverter))] public sealed partial class ExplainDataLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycleExplain))] public IReadOnlyDictionary Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs index 32d5670584b..131019e41b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs @@ -103,6 +103,11 @@ public FieldUsageStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : b { } + [JsonConstructor] + internal FieldUsageStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementFieldUsageStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -111,6 +116,14 @@ public FieldUsageStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : b internal override string OperationName => "indices.field_usage_stats"; + /// + /// + /// Comma-separated list or wildcard expression of index names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs index f5e5ded303a..4861338f093 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class FieldUsageStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override FieldUsageStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldUsageStatsResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldUsageStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldUsageStatsResponseConverter))] public sealed partial class FieldUsageStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs index c11cb3fc5ee..d0fb378a18e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs @@ -92,6 +92,7 @@ public sealed partial class FlushRequestParameters : RequestParameters /// public sealed partial class FlushRequest : PlainRequest { + [JsonConstructor] public FlushRequest() { } @@ -108,6 +109,16 @@ public FlushRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "indices.flush"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to flush. + /// Supports wildcards (*). + /// To flush all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs index a65538aaae8..5c14796bc47 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushResponseConverter))] public sealed partial class FlushResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs index 9059a333f91..32a56995281 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs @@ -103,6 +103,7 @@ public sealed partial class ForcemergeRequestParameters : RequestParameters /// public sealed partial class ForcemergeRequest : PlainRequest { + [JsonConstructor] public ForcemergeRequest() { } @@ -119,6 +120,14 @@ public ForcemergeRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.forcemerge"; + /// + /// + /// A comma-separated list of index names; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs index 31e852e84b8..75ca468657b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propShards = default; + LocalJsonValue propTask = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propTask.TryReadProperty(ref reader, options, PropTask, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTask, value.Task, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForcemergeResponseConverter))] public sealed partial class ForcemergeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } /// @@ -37,6 +87,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/_Generated/Api/IndexManagement/GetAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs index 0b66e257a11..00ae231b3dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs @@ -74,6 +74,7 @@ public sealed partial class GetAliasRequestParameters : RequestParameters /// public sealed partial class GetAliasRequest : PlainRequest { + [JsonConstructor] public GetAliasRequest() { } @@ -98,6 +99,26 @@ public GetAliasRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.get_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list of aliases to retrieve. + /// Supports wildcards (*). + /// To retrieve all aliases, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs index 49f3058f361..57573498e9c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs @@ -68,6 +68,11 @@ public GetDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam { } + [JsonConstructor] + internal GetDataLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementGetDataLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -76,6 +81,16 @@ public GetDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.get_data_lifecycle"; + /// + /// + /// Comma-separated list of data streams to limit the request. + /// Supports wildcards (*). + /// To target all data streams, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs index 9fcbcfc0c5c..b2e8ed77340 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryReadProperty(ref reader, options, PropDataStreams, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs index ce6a1e7e754..d5247534d53 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs @@ -70,6 +70,7 @@ public sealed partial class GetDataStreamRequestParameters : RequestParameters /// public sealed partial class GetDataStreamRequest : PlainRequest { + [JsonConstructor] public GetDataStreamRequest() { } @@ -86,6 +87,15 @@ public GetDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamNames? name) internal override string OperationName => "indices.get_data_stream"; + /// + /// + /// Comma-separated list of data stream names used to limit the request. + /// Wildcard (*) expressions are supported. If omitted, all data streams are returned. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames? Name { get => P("name"); set => PO("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs index f6c1a882edf..30971ee1647 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryReadProperty(ref reader, options, PropDataStreams, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs index 960c83e0bab..026c0850160 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs @@ -89,6 +89,11 @@ public GetFieldMappingRequest(Elastic.Clients.Elasticsearch.Indices? indices, El { } + [JsonConstructor] + internal GetFieldMappingRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementGetFieldMapping; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -97,6 +102,24 @@ public GetFieldMappingRequest(Elastic.Clients.Elasticsearch.Indices? indices, El internal override string OperationName => "indices.get_field_mapping"; + /// + /// + /// Comma-separated list or wildcard expression of fields used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Fields Fields { get => P("fields"); set => PR("fields", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs index 69965de963b..275d38521ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs @@ -106,6 +106,11 @@ public GetIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r = { } + [JsonConstructor] + internal GetIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -114,6 +119,15 @@ public GetIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r = internal override string OperationName => "indices.get"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. + /// Wildcard expressions (*) are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs index b4c809766b6..186968bb57c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs @@ -69,6 +69,7 @@ public sealed partial class GetIndexTemplateRequestParameters : RequestParameter /// public sealed partial class GetIndexTemplateRequest : PlainRequest { + [JsonConstructor] public GetIndexTemplateRequest() { } @@ -85,6 +86,14 @@ public GetIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : base( internal override string OperationName => "indices.get_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs index bc57e63ef5e..b67ac650f3d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propIndexTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndexTemplates.TryReadProperty(ref reader, options, PropIndexTemplates, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs index 64fa5aa087b..78ed612154e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs @@ -100,6 +100,7 @@ public sealed partial class GetIndicesSettingsRequestParameters : RequestParamet /// public sealed partial class GetIndicesSettingsRequest : PlainRequest { + [JsonConstructor] public GetIndicesSettingsRequest() { } @@ -124,6 +125,24 @@ public GetIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Names? name) : ba internal override string OperationName => "indices.get_settings"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit + /// the request. Supports wildcards (*). To target all data streams and + /// indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list or wildcard expression of settings to retrieve. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs index ef614f8fa4e..72faf2ba96d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs @@ -82,6 +82,7 @@ public sealed partial class GetMappingRequestParameters : RequestParameters /// public sealed partial class GetMappingRequest : PlainRequest { + [JsonConstructor] public GetMappingRequest() { } @@ -98,6 +99,16 @@ public GetMappingRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.get_mapping"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs index e65ca2399a7..0a60be35261 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs @@ -63,6 +63,7 @@ public sealed partial class GetTemplateRequestParameters : RequestParameters /// public sealed partial class GetTemplateRequest : PlainRequest { + [JsonConstructor] public GetTemplateRequest() { } @@ -79,6 +80,16 @@ public GetTemplateRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => internal override string OperationName => "indices.get_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// To return all index templates, omit this parameter or use a value of _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs index ec9c41d2b62..e72681f3ad8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs @@ -118,6 +118,7 @@ public sealed partial class IndicesStatsRequestParameters : RequestParameters /// public sealed partial class IndicesStatsRequest : PlainRequest { + [JsonConstructor] public IndicesStatsRequest() { } @@ -142,6 +143,22 @@ public IndicesStatsRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elast internal override string OperationName => "indices.stats"; + /// + /// + /// A comma-separated list of index names; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Limit the information returned the specific metrics. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs index 7a78a645850..1c8788faddf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAll = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAll.TryReadProperty(ref reader, options, PropAll, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndicesStatsResponseConverter))] public sealed partial class IndicesStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_all")] public Elastic.Clients.Elasticsearch.IndexManagement.IndicesStats All { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyDictionary? Indices { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs index c58975294e3..98f5c0abd82 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs @@ -68,6 +68,11 @@ public MigrateToDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) { } + [JsonConstructor] + internal MigrateToDataStreamRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementMigrateToDataStream; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -76,6 +81,14 @@ public MigrateToDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) internal override string OperationName => "indices.migrate_to_data_stream"; + /// + /// + /// Name of the index alias to convert to a data stream. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs index 48d6aa2e95e..9a73b735fb9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MigrateToDataStreamResponseConverter))] public sealed partial class MigrateToDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/ModifyDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamRequest.g.cs index 38fe2a811e1..eddb720d1de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class ModifyDataStreamRequestParameters : RequestParameter /// public sealed partial class ModifyDataStreamRequest : PlainRequest { + [JsonConstructor] + internal ModifyDataStreamRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementModifyDataStream; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs index f55c2d8935d..68243483e55 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ModifyDataStreamResponseConverter))] public sealed partial class ModifyDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs index b1a51e3447a..675a759744b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs @@ -94,6 +94,11 @@ public OpenIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r { } + [JsonConstructor] + internal OpenIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementOpen; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -102,6 +107,18 @@ public OpenIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.open"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// By default, you must explicitly name the indices you using to limit the request. + /// To limit a request using _all, *, or other wildcard expressions, change the action.destructive_requires_name setting to false. + /// You can update this setting in the elasticsearch.yml file or using the cluster update settings API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs index bfbbff8b77c..bf4f7b17d41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + 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/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs index 1ba3ecb759f..5c2f7431e35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs @@ -63,6 +63,11 @@ public PromoteDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) : { } + [JsonConstructor] + internal PromoteDataStreamRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPromoteDataStream; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -71,6 +76,14 @@ public PromoteDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) : internal override string OperationName => "indices.promote_data_stream"; + /// + /// + /// The name of the data stream + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs index 19d5e829a83..218b177060f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs @@ -61,6 +61,11 @@ public PutAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.Cl { } + [JsonConstructor] + internal PutAliasRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutAlias; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -69,6 +74,26 @@ public PutAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.Cl internal override string OperationName => "indices.put_alias"; + /// + /// + /// Comma-separated list of data streams or indices to add. + /// Supports wildcards (*). + /// Wildcard patterns that match both data streams and indices return an error. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// Alias to update. + /// If the alias doesn’t exist, the request creates it. + /// Index alias names support date math. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs index 4b2d5f8e957..7080329ac3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutAliasResponseConverter))] public sealed partial class PutAliasResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs index 85d023869c7..18d287d1824 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs @@ -59,18 +59,37 @@ public sealed partial class PutDataLifecycleRequestParameters : RequestParameter public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } } +internal sealed partial class PutDataLifecycleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override PutDataLifecycleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new PutDataLifecycleRequest { Lifecycle = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDataLifecycleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Lifecycle, null); + } +} + /// /// /// Update data stream lifecycles. /// Update the data stream lifecycle of the specified data streams. /// /// -public sealed partial class PutDataLifecycleRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(PutDataLifecycleRequestConverter))] +public sealed partial class PutDataLifecycleRequest : PlainRequest { public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames name) : base(r => r.Required("name", name)) { } + [JsonConstructor] + internal PutDataLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutDataLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -79,6 +98,15 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.put_data_lifecycle"; + /// + /// + /// Comma-separated list of data streams used to limit the request. + /// Supports wildcards (*). + /// To target all data streams use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. @@ -86,7 +114,6 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam /// Valid values are: all, hidden, open, closed, none. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -96,7 +123,6 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam /// error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -105,15 +131,8 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycle Lifecycle { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Lifecycle, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs index ba771b59fb4..b0bbf8f2f3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDataLifecycleResponseConverter))] public sealed partial class PutDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs index 614820e2fd8..f5c5060ca54 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs @@ -67,6 +67,11 @@ public PutIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r { } + [JsonConstructor] + internal PutIndexTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutIndexTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -75,6 +80,14 @@ public PutIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "indices.put_index_template"; + /// + /// + /// Index or template name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// User defined reason for creating/updating the index template diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs index ca9c859e0ba..686a79b1aed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndexTemplateResponseConverter))] public sealed partial class PutIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs index 9eb516eb4e1..5b549a4c36d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs @@ -92,6 +92,19 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } } +internal sealed partial class PutIndicesSettingsRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override PutIndicesSettingsRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new PutIndicesSettingsRequest { Settings = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIndicesSettingsRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Settings, null); + } +} + /// /// /// Update index settings. @@ -99,8 +112,10 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet /// changes are applied to all backing indices by default. /// /// -public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(PutIndicesSettingsRequestConverter))] +public sealed partial class PutIndicesSettingsRequest : PlainRequest { + [JsonConstructor] public PutIndicesSettingsRequest() { } @@ -117,6 +132,15 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) internal override string OperationName => "indices.put_settings"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit + /// the request. Supports wildcards (*). To target all data streams and + /// indices, omit this parameter or use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index @@ -126,7 +150,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// starts with foo but no index starts with bar. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -137,7 +160,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -145,7 +167,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, returns settings in flat format. /// /// - [JsonIgnore] public bool? FlatSettings { get => Q("flat_settings"); set => Q("flat_settings", value); } /// @@ -153,7 +174,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, returns settings in flat format. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -163,7 +183,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -171,7 +190,6 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, existing index settings remain unchanged. /// /// - [JsonIgnore] public bool? PreserveExisting { get => Q("preserve_existing"); set => Q("preserve_existing", value); } /// @@ -180,15 +198,8 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings Settings { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Settings, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs index f5ada21c60d..16b2fdafe0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndicesSettingsResponseConverter))] public sealed partial class PutIndicesSettingsResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/PutMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs index 708c10deaef..914fc851763 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs @@ -81,6 +81,144 @@ 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); + LocalJsonValue propDateDetection = default; + LocalJsonValue propDynamic = default; + LocalJsonValue?> propDynamicDateFormats = default; + LocalJsonValue>?> propDynamicTemplates = default; + LocalJsonValue propFieldNames = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNumericDetection = default; + LocalJsonValue propProperties = default; + LocalJsonValue propRouting = default; + LocalJsonValue?> propRuntime = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDateDetection.TryReadProperty(ref reader, options, PropDateDetection, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propDynamicDateFormats.TryReadProperty(ref reader, options, PropDynamicDateFormats, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propDynamicTemplates.TryReadProperty(ref reader, options, PropDynamicTemplates, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, static IDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!))) + { + continue; + } + + if (propFieldNames.TryReadProperty(ref reader, options, PropFieldNames, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNumericDetection.TryReadProperty(ref reader, options, PropNumericDetection, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propRuntime.TryReadProperty(ref reader, options, PropRuntime, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropDynamicDateFormats, value.DynamicDateFormats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropDynamicTemplates, value.DynamicTemplates, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteSingleOrManyCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropFieldNames, value.FieldNames, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNumericDetection, value.NumericDetection, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropRuntime, value.Runtime, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Update field mappings. @@ -89,12 +227,18 @@ public sealed partial class PutMappingRequestParameters : RequestParameters /// For data streams, these changes are applied to all backing indices by default. /// /// +[JsonConverter(typeof(PutMappingRequestConverter))] public sealed partial class PutMappingRequest : PlainRequest { public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) { } + [JsonConstructor] + internal PutMappingRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutMapping; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -103,13 +247,19 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.put_mapping"; + /// + /// + /// A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices. + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. /// 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); } /// @@ -120,7 +270,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Valid values are: all, open, closed, hidden, none. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -128,7 +277,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// 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); } /// @@ -137,7 +285,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -146,7 +293,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -154,7 +300,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// 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); } /// @@ -162,7 +307,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Controls whether dynamic date detection is enabled. /// /// - [JsonInclude, JsonPropertyName("date_detection")] public bool? DateDetection { get; set; } /// @@ -170,7 +314,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Controls whether new fields are added dynamically. /// /// - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } /// @@ -180,7 +323,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// a new date field is added instead of string. /// /// - [JsonInclude, JsonPropertyName("dynamic_date_formats")] public ICollection? DynamicDateFormats { get; set; } /// @@ -188,8 +330,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Specify dynamic templates for the mapping. /// /// - [JsonInclude, JsonPropertyName("dynamic_templates")] - [SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary))] public ICollection>? DynamicTemplates { get; set; } /// @@ -197,7 +337,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Control whether field names are enabled for the index. /// /// - [JsonInclude, JsonPropertyName("_field_names")] public Elastic.Clients.Elasticsearch.Mapping.FieldNamesField? FieldNames { get; set; } /// @@ -207,7 +346,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// application-specific metadata. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IDictionary? Meta { get; set; } /// @@ -215,7 +353,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Automatically map strings into numeric data types for all fields. /// /// - [JsonInclude, JsonPropertyName("numeric_detection")] public bool? NumericDetection { get; set; } /// @@ -240,7 +377,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// /// /// - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } /// @@ -248,7 +384,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Enable making a routing value required on indexed documents. /// /// - [JsonInclude, JsonPropertyName("_routing")] public Elastic.Clients.Elasticsearch.Mapping.RoutingField? Routing { get; set; } /// @@ -256,7 +391,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Mapping of runtime fields for the index. /// /// - [JsonInclude, JsonPropertyName("runtime")] public IDictionary? Runtime { get; set; } /// @@ -264,7 +398,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Control whether the _source field is enabled on the index. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Mapping.SourceField? Source { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs index ee2d54544d5..6c6cde56913 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutMappingResponseConverter))] public sealed partial class PutMappingResponse : ElasticsearchResponse { /// @@ -33,8 +84,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.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs index 6c14ce93433..a48e46b9912 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs @@ -50,6 +50,94 @@ public sealed partial class PutTemplateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } } +internal sealed partial class PutTemplateRequestConverter : 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 PropIndexPatterns = System.Text.Json.JsonEncodedText.Encode("index_patterns"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutTemplateRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAliases = default; + LocalJsonValue?> propIndexPatterns = default; + LocalJsonValue propMappings = default; + LocalJsonValue propOrder = default; + LocalJsonValue propSettings = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAliases.TryReadProperty(ref reader, options, PropAliases, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propIndexPatterns.TryReadProperty(ref reader, options, PropIndexPatterns, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMappings.TryReadProperty(ref reader, options, PropMappings, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, null)) + { + continue; + } + + if (propSettings.TryReadProperty(ref reader, options, PropSettings, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTemplateRequest + { + Aliases = propAliases.Value + , + IndexPatterns = propIndexPatterns.Value + , + Mappings = propMappings.Value + , + Order = propOrder.Value + , + Settings = propSettings.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTemplateRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAliases, value.Aliases, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropIndexPatterns, value.IndexPatterns, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMappings, value.Mappings, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, null); + writer.WriteProperty(options, PropSettings, value.Settings, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Create or update an index template. @@ -69,12 +157,18 @@ public sealed partial class PutTemplateRequestParameters : RequestParameters /// Settings and mappings specified in create index API requests override any settings or mappings specified in an index template. /// /// +[JsonConverter(typeof(PutTemplateRequestConverter))] public sealed partial class PutTemplateRequest : PlainRequest { public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) { } + [JsonConstructor] + internal PutTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -83,7 +177,12 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r internal override string OperationName => "indices.put_template"; - [JsonIgnore] + /// + /// + /// The name of the template + /// + /// + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } public string? Cause { get => Q("cause"); set => Q("cause", value); } /// @@ -91,7 +190,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// If true, this request cannot replace or update existing index templates. /// /// - [JsonIgnore] public bool? Create { get => Q("create"); set => Q("create", value); } /// @@ -100,7 +198,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -108,7 +205,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Aliases for the index. /// /// - [JsonInclude, JsonPropertyName("aliases")] public IDictionary? Aliases { get; set; } /// @@ -117,8 +213,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// of indices during creation. /// /// - [JsonInclude, JsonPropertyName("index_patterns")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? IndexPatterns { get; set; } /// @@ -126,7 +220,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Mapping for fields in the index. /// /// - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping? Mappings { get; set; } /// @@ -139,7 +232,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// 'order' values are merged later, overriding templates with lower values. /// /// - [JsonInclude, JsonPropertyName("order")] public int? Order { get; set; } /// @@ -147,7 +239,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Configuration options for the index. /// /// - [JsonInclude, JsonPropertyName("settings")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? Settings { get; set; } /// @@ -156,7 +247,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs index 45918fda300..e292e261bfb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTemplateResponseConverter))] public sealed partial class PutTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class PutTemplateResponse : 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/_Generated/Api/IndexManagement/RecoveryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs index fa16870effe..1e5c43afd9a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs @@ -103,6 +103,7 @@ public sealed partial class RecoveryRequestParameters : RequestParameters /// public sealed partial class RecoveryRequest : PlainRequest { + [JsonConstructor] public RecoveryRequest() { } @@ -119,6 +120,16 @@ public RecoveryRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.recovery"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If true, the response only includes ongoing shard recoveries. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs index 7b6446a62d7..9b279f49f8e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs @@ -67,6 +67,7 @@ public sealed partial class RefreshRequestParameters : RequestParameters /// public sealed partial class RefreshRequest : PlainRequest { + [JsonConstructor] public RefreshRequest() { } @@ -83,6 +84,16 @@ public RefreshRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r = internal override string OperationName => "indices.refresh"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs index 173d7f57182..5bd32cae870 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RefreshResponseConverter))] public sealed partial class RefreshResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs index 736815127c6..de38bce6c40 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs @@ -81,6 +81,11 @@ public ReloadSearchAnalyzersRequest(Elastic.Clients.Elasticsearch.Indices indice { } + [JsonConstructor] + internal ReloadSearchAnalyzersRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementReloadSearchAnalyzers; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -89,6 +94,14 @@ public ReloadSearchAnalyzersRequest(Elastic.Clients.Elasticsearch.Indices indice internal override string OperationName => "indices.reload_search_analyzers"; + /// + /// + /// A comma-separated list of index names to reload analyzers for + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs index 63b89ee9ae3..4ff6b913f80 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ReloadSearchAnalyzersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadDetails = System.Text.Json.JsonEncodedText.Encode("reload_details"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ReloadSearchAnalyzersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propReloadDetails = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadDetails.TryReadProperty(ref reader, options, PropReloadDetails, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReloadSearchAnalyzersResponse + { + ReloadDetails = propReloadDetails.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReloadSearchAnalyzersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadDetails, value.ReloadDetails, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReloadSearchAnalyzersResponseConverter))] public sealed partial class ReloadSearchAnalyzersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("reload_details")] public IReadOnlyCollection ReloadDetails { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs index 3081c88ff9d..2303ce96375 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs @@ -116,6 +116,11 @@ public ResolveClusterRequest(Elastic.Clients.Elasticsearch.Names name) : base(r { } + [JsonConstructor] + internal ResolveClusterRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementResolveCluster; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -124,6 +129,15 @@ public ResolveClusterRequest(Elastic.Clients.Elasticsearch.Names name) : base(r internal override string OperationName => "indices.resolve_cluster"; + /// + /// + /// Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + /// Resources on remote clusters can be specified using the <cluster>:<name> syntax. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs index 453bca1e4ff..012ffc1f7f8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs @@ -72,6 +72,11 @@ public ResolveIndexRequest(Elastic.Clients.Elasticsearch.Names name) : base(r => { } + [JsonConstructor] + internal ResolveIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementResolveIndex; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -80,6 +85,15 @@ public ResolveIndexRequest(Elastic.Clients.Elasticsearch.Names name) : base(r => internal override string OperationName => "indices.resolve_index"; + /// + /// + /// Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + /// Resources on remote clusters can be specified using the <cluster>:<name> syntax. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs index 9fa71a9fca0..936fb8a8d6d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propAliases = default; + LocalJsonValue> propDataStreams = default; + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAliases.TryReadProperty(ref reader, options, PropAliases, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propDataStreams.TryReadProperty(ref reader, options, PropDataStreams, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropDataStreams, value.DataStreams, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/IndexManagement/RolloverRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs index 4d0efc47482..f875c13e76f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs @@ -80,6 +80,11 @@ public RolloverRequest(Elastic.Clients.Elasticsearch.IndexAlias alias, Elastic.C { } + [JsonConstructor] + internal RolloverRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementRollover; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -88,6 +93,24 @@ public RolloverRequest(Elastic.Clients.Elasticsearch.IndexAlias alias, Elastic.C internal override string OperationName => "indices.rollover"; + /// + /// + /// Name of the data stream or index alias to roll over. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexAlias Alias { get => P("alias"); set => PR("alias", value); } + + /// + /// + /// Name of the index to create. + /// Supports date math. + /// Data streams do not support this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? NewIndex { get => P("new_index"); set => PO("new_index", value); } + /// /// /// If true, checks whether the current index satisfies the specified conditions but does not perform a rollover. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs index cf9804a869f..d072119028e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs @@ -22,24 +22,118 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propConditions = default; + LocalJsonValue propDryRun = default; + LocalJsonValue propNewIndex = default; + LocalJsonValue propOldIndex = default; + LocalJsonValue propRolledOver = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propConditions.TryReadProperty(ref reader, options, PropConditions, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propDryRun.TryReadProperty(ref reader, options, PropDryRun, null)) + { + continue; + } + + if (propNewIndex.TryReadProperty(ref reader, options, PropNewIndex, null)) + { + continue; + } + + if (propOldIndex.TryReadProperty(ref reader, options, PropOldIndex, null)) + { + continue; + } + + if (propRolledOver.TryReadProperty(ref reader, options, PropRolledOver, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropConditions, value.Conditions, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropDryRun, value.DryRun, null, null); + writer.WriteProperty(options, PropNewIndex, value.NewIndex, null, null); + writer.WriteProperty(options, PropOldIndex, value.OldIndex, null, null); + writer.WriteProperty(options, PropRolledOver, value.RolledOver, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + 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/_Generated/Api/IndexManagement/SegmentsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs index 935d749c917..84864a6cfaf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs @@ -67,6 +67,7 @@ public sealed partial class SegmentsRequestParameters : RequestParameters /// public sealed partial class SegmentsRequest : PlainRequest { + [JsonConstructor] public SegmentsRequest() { } @@ -83,6 +84,16 @@ public SegmentsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.segments"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs index eba31e77e85..b3570e5484f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propIndices = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + 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.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs index 7214e3d289d..9c03066fd2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs @@ -101,6 +101,7 @@ public sealed partial class ShardStoresRequestParameters : RequestParameters /// public sealed partial class ShardStoresRequest : PlainRequest { + [JsonConstructor] public ShardStoresRequest() { } @@ -117,6 +118,14 @@ public ShardStoresRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base internal override string OperationName => "indices.shard_stores"; + /// + /// + /// List of data streams, indices, and aliases used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs index 09e274b9898..469c78bd969 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs @@ -22,13 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ShardStoresResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ShardStoresResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShardStoresResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoresResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShardStoresResponseConverter))] public sealed partial class ShardStoresResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.IndicesShardStores))] public IReadOnlyDictionary Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs index ad7eb567dd7..364b7c4b7b3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs @@ -152,6 +152,11 @@ public ShrinkIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic { } + [JsonConstructor] + internal ShrinkIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementShrink; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -160,6 +165,22 @@ public ShrinkIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic internal override string OperationName => "indices.shrink"; + /// + /// + /// Name of the source index to shrink. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs index 5cdc0a85eaf..4b88a086a2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ShrinkIndexResponseConverter : 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 ShrinkIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShrinkIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShrinkIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShrinkIndexResponseConverter))] public sealed partial class ShrinkIndexResponse : 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/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs index 94431e9a878..712fef6fd77 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs @@ -59,6 +59,11 @@ public SimulateIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : b { } + [JsonConstructor] + internal SimulateIndexTemplateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementSimulateIndexTemplate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -67,6 +72,14 @@ public SimulateIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : b internal override string OperationName => "indices.simulate_index_template"; + /// + /// + /// Name of the index to simulate + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, returns all relevant default configurations for the index template. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs index 1319b5304d7..48588e3ad51 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propOverlapping = default; + LocalJsonValue propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryReadProperty(ref reader, options, PropOverlapping, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTemplate.TryReadProperty(ref reader, options, PropTemplate, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTemplate, value.Template, null, null); + 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.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs index 51e33f2427e..df25959ac88 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs @@ -62,6 +62,7 @@ public sealed partial class SimulateTemplateRequestParameters : RequestParameter /// public sealed partial class SimulateTemplateRequest : PlainRequest { + [JsonConstructor] public SimulateTemplateRequest() { } @@ -78,6 +79,15 @@ public SimulateTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : base( internal override string OperationName => "indices.simulate_template"; + /// + /// + /// Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit + /// this parameter and specify the template configuration in the request body. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs index 13d495ed53a..09f099abe22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propOverlapping = default; + LocalJsonValue propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryReadProperty(ref reader, options, PropOverlapping, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTemplate.TryReadProperty(ref reader, options, PropTemplate, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTemplate, value.Template, null, null); + 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.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs index de7ea89236b..c8cd3b162ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs @@ -141,6 +141,11 @@ public SplitIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. { } + [JsonConstructor] + internal SplitIndexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementSplit; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -149,6 +154,22 @@ public SplitIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.split"; + /// + /// + /// Name of the source index to split. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs index f029453776f..db2d21f8ea8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class SplitIndexResponseConverter : 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 SplitIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propShardsAcknowledged.TryReadProperty(ref reader, options, PropShardsAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SplitIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SplitIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SplitIndexResponseConverter))] public sealed partial class SplitIndexResponse : 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/_Generated/Api/IndexManagement/UpdateAliasesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesRequest.g.cs index 259de6072e3..bd910f9b2db 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesRequest.g.cs @@ -57,6 +57,11 @@ public sealed partial class UpdateAliasesRequestParameters : RequestParameters /// public sealed partial class UpdateAliasesRequest : PlainRequest { + [JsonConstructor] + internal UpdateAliasesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementUpdateAliases; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs index 5b7fd8e987a..fda9b3bc3c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateAliasesResponseConverter))] public sealed partial class UpdateAliasesResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs index 0f5e89c0d8b..cbb2654a9e0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs @@ -131,6 +131,7 @@ public sealed partial class ValidateQueryRequestParameters : RequestParameters /// public sealed partial class ValidateQueryRequest : PlainRequest { + [JsonConstructor] public ValidateQueryRequest() { } @@ -147,6 +148,16 @@ public ValidateQueryRequest(Elastic.Clients.Elasticsearch.Indices? indices) : ba internal override string OperationName => "indices.validate_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs index 90f6de37d06..9a96f74f1f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propError = default; + LocalJsonValue?> propExplanations = default; + LocalJsonValue propShards = default; + LocalJsonValue propValid = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propError.TryReadProperty(ref reader, options, PropError, null)) + { + continue; + } + + if (propExplanations.TryReadProperty(ref reader, options, PropExplanations, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propValid.TryReadProperty(ref reader, options, PropValid, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExplanations, value.Explanations, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropValid, value.Valid, null, null); + 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.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/_Generated/Api/IndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs index 2722f0c9b24..40ec294e75a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs @@ -120,6 +120,36 @@ public sealed partial class IndexRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } } +internal sealed partial class IndexRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + public override IndexRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new IndexRequest { Document = reader.ReadValue(options, static TDocument (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker))!) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Document, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + } +} + +internal sealed partial class IndexRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(IndexRequest<>); + } + + 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(IndexRequestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Index a document. @@ -127,7 +157,8 @@ 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 +[JsonConverter(typeof(IndexRequestConverterFactory))] +public sealed partial class IndexRequest : PlainRequest { public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", index).Optional("id", id)) { @@ -137,6 +168,11 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r { } + [JsonConstructor] + public IndexRequest() : this(typeof(TDocument)) + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceIndex; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -145,12 +181,25 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r internal override string OperationName => "index"; + /// + /// + /// Unique identifier for the document. + /// + /// + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + + /// + /// + /// Name of the data stream or index to target. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// 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); } /// @@ -158,7 +207,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// 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); } /// @@ -171,7 +219,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Otherwise, it defaults to create. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.OpType? OpType { get => Q("op_type"); set => Q("op_type", value); } /// @@ -181,7 +228,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// If a final pipeline is configured it will always run, regardless of the value of this parameter. /// /// - [JsonIgnore] public string? Pipeline { get => Q("pipeline"); set => Q("pipeline", value); } /// @@ -190,7 +236,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Valid values: true, false, wait_for. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } /// @@ -198,7 +243,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// If true, the destination must be an index alias. /// /// - [JsonIgnore] public bool? RequireAlias { get => Q("require_alias"); set => Q("require_alias", value); } /// @@ -206,7 +250,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -214,7 +257,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -223,7 +265,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// The specified version must match the current version of the document for the request to succeed. /// /// - [JsonIgnore] public long? Version { get => Q("version"); set => Q("version", value); } /// @@ -231,7 +272,6 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Specific version type: external, external_gte. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } /// @@ -240,15 +280,8 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } - [JsonIgnore] public TDocument Document { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - settings.SourceSerializer.Serialize(Document, writer); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs index 289d66cf21d..e9f82d65402 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs @@ -22,26 +22,129 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Inference/DeleteInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs index d8514b99866..7d34616820a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs @@ -62,6 +62,11 @@ public DeleteInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? { } + [JsonConstructor] + internal DeleteInferenceRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.InferenceDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -70,6 +75,22 @@ public DeleteInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? internal override string OperationName => "inference.delete"; + /// + /// + /// The inference Id + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } + /// /// /// When true, the endpoint is not deleted, and a list of ingest processors which reference this endpoint is returned diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs index 2e7e80f69d3..a6f331fe988 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propPipelines = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propPipelines.TryReadProperty(ref reader, options, PropPipelines, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropPipelines, value.Pipelines, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteInferenceResponseConverter))] public sealed partial class DeleteInferenceResponse : ElasticsearchResponse { /// @@ -33,8 +84,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/_Generated/Api/Inference/GetInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs index 40c96fe6b8d..711b79e8179 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs @@ -41,6 +41,7 @@ public sealed partial class GetInferenceRequestParameters : RequestParameters /// public sealed partial class GetInferenceRequest : PlainRequest { + [JsonConstructor] public GetInferenceRequest() { } @@ -60,6 +61,22 @@ public GetInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? tas internal override bool SupportsBody => false; internal override string OperationName => "inference.get"; + + /// + /// + /// The inference Id + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? InferenceId { get => P("inference_id"); set => PO("inference_id", value); } + + /// + /// + /// The task type + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs index 254b29ef133..54b29f4fc09 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propEndpoints = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEndpoints.TryReadProperty(ref reader, options, PropEndpoints, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Inference/InferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs index 8c0ff5643b7..6fd47ce5ad0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs @@ -40,11 +40,70 @@ public sealed partial class InferenceRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propInput = default; + LocalJsonValue propQuery = default; + LocalJsonValue propTaskSettings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInput.TryReadProperty(ref reader, options, PropInput, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propTaskSettings.TryReadProperty(ref reader, options, PropTaskSettings, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Perform inference on the service /// /// +[JsonConverter(typeof(InferenceRequestConverter))] public sealed partial class InferenceRequest : PlainRequest { public InferenceRequest(Elastic.Clients.Elasticsearch.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) @@ -55,6 +114,11 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy { } + [JsonConstructor] + internal InferenceRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.InferenceInference; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -63,12 +127,25 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy internal override string OperationName => "inference.inference"; + /// + /// + /// The inference Id + /// + /// + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } + /// /// /// Specifies the amount of time to wait for the inference request to complete. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -77,8 +154,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Either a string or an array of strings. /// /// - [JsonInclude, JsonPropertyName("input")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection Input { get; set; } /// @@ -87,7 +162,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Not required for other tasks. /// /// - [JsonInclude, JsonPropertyName("query")] public string? Query { get; set; } /// @@ -95,7 +169,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Optional task settings /// /// - [JsonInclude, JsonPropertyName("task_settings")] public object? TaskSettings { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs index fb55c4afc55..736bbb4ae79 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs @@ -22,10 +22,39 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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) + { + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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/_Generated/Api/Inference/PutInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs index 2b49b107239..9898aaf4062 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs @@ -34,6 +34,19 @@ public sealed partial class PutInferenceRequestParameters : RequestParameters { } +internal sealed partial class PutInferenceRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override PutInferenceRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new PutInferenceRequest { InferenceConfig = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutInferenceRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.InferenceConfig, null); + } +} + /// /// /// Create an inference endpoint. @@ -49,7 +62,8 @@ 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 +[JsonConverter(typeof(PutInferenceRequestConverter))] +public sealed partial class PutInferenceRequest : PlainRequest { public PutInferenceRequest(Elastic.Clients.Elasticsearch.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) { @@ -59,6 +73,11 @@ public PutInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? tas { } + [JsonConstructor] + internal PutInferenceRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.InferencePut; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -67,13 +86,20 @@ public PutInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? tas internal override string OperationName => "inference.put"; - [JsonIgnore] + /// + /// + /// The inference Id + /// + /// + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } public Elastic.Clients.Elasticsearch.Inference.InferenceEndpoint InferenceConfig { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, InferenceConfig, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs index dca82330fc2..8d975488a1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propInferenceId = default; + LocalJsonValue propService = default; + LocalJsonValue propServiceSettings = default; + LocalJsonValue propTaskSettings = default; + LocalJsonValue propTaskType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceId.TryReadProperty(ref reader, options, PropInferenceId, null)) + { + continue; + } + + if (propService.TryReadProperty(ref reader, options, PropService, null)) + { + continue; + } + + if (propServiceSettings.TryReadProperty(ref reader, options, PropServiceSettings, null)) + { + continue; + } + + if (propTaskSettings.TryReadProperty(ref reader, options, PropTaskSettings, null)) + { + continue; + } + + if (propTaskType.TryReadProperty(ref reader, options, PropTaskType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropService, value.Service, null, null); + writer.WriteProperty(options, PropServiceSettings, value.ServiceSettings, null, null); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings, null, null); + writer.WriteProperty(options, PropTaskType, value.TaskType, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutInferenceResponseConverter))] public sealed partial class PutInferenceResponse : ElasticsearchResponse { /// @@ -33,7 +114,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The inference Id /// /// - [JsonInclude, JsonPropertyName("inference_id")] public string InferenceId { get; init; } /// @@ -41,7 +121,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The service type /// /// - [JsonInclude, JsonPropertyName("service")] public string Service { get; init; } /// @@ -49,7 +128,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// Settings specific to the service /// /// - [JsonInclude, JsonPropertyName("service_settings")] public object ServiceSettings { get; init; } /// @@ -57,7 +135,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 +142,5 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The task type /// /// - [JsonInclude, JsonPropertyName("task_type")] public Elastic.Clients.Elasticsearch.Inference.TaskType TaskType { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoRequest.g.cs index 9d5e5290857..c59427d7b6d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class InfoRequestParameters : RequestParameters /// public sealed partial class InfoRequest : PlainRequest { + [JsonConstructor] + internal InfoRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs index 0558e1d8735..c0be981f261 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propClusterName = default; + LocalJsonValue propClusterUuid = default; + LocalJsonValue propName = default; + LocalJsonValue propTagline = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propClusterUuid.TryReadProperty(ref reader, options, PropClusterUuid, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propTagline.TryReadProperty(ref reader, options, PropTagline, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropTagline, value.Tagline, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InfoResponseConverter))] public sealed partial class InfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } - [JsonInclude, JsonPropertyName("tagline")] public string Tagline { get; init; } - [JsonInclude, JsonPropertyName("version")] public Elastic.Clients.Elasticsearch.ElasticsearchVersionInfo Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs index 26a49ab502d..4f2cb537616 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs @@ -60,6 +60,11 @@ public DeleteGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : base(r { } + [JsonConstructor] + internal DeleteGeoipDatabaseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestDeleteGeoipDatabase; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -68,6 +73,14 @@ public DeleteGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : base(r internal override string OperationName => "ingest.delete_geoip_database"; + /// + /// + /// A comma-separated list of geoip database configurations to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs index dce6d2f572a..c435c8ee0f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteGeoipDatabaseResponseConverter))] public sealed partial class DeleteGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs index c59c95fc2ab..98ac3353f9b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs @@ -62,6 +62,11 @@ public DeleteIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : b { } + [JsonConstructor] + internal DeleteIpLocationDatabaseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestDeleteIpLocationDatabase; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -70,6 +75,14 @@ public DeleteIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : b internal override string OperationName => "ingest.delete_ip_location_database"; + /// + /// + /// A comma-separated list of IP location database configurations. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Id { get => P("id"); set => PR("id", value); } + /// /// /// The period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs index d221599c779..0a2705d5fdc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIpLocationDatabaseResponseConverter))] public sealed partial class DeleteIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/DeletePipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs index bae10014caa..aba789a5bab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs @@ -61,6 +61,11 @@ public DeletePipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. { } + [JsonConstructor] + internal DeletePipelineRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestDeletePipeline; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -69,6 +74,15 @@ public DeletePipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override string OperationName => "ingest.delete_pipeline"; + /// + /// + /// Pipeline ID or wildcard expression of pipeline IDs used to limit the request. + /// To delete all ingest pipelines in a cluster, use a value of *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs index a56624fd181..2df19b5905d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePipelineResponseConverter))] public sealed partial class DeletePipelineResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/GeoIpStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsRequest.g.cs index 7ca7d51ee62..0da33b2298f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class GeoIpStatsRequestParameters : RequestParameters /// public sealed partial class GeoIpStatsRequest : PlainRequest { + [JsonConstructor] + internal GeoIpStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestGeoIpStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs index dc229b51599..63d5b9f3797 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propNodes = default; + LocalJsonValue propStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propStats.TryReadProperty(ref reader, options, PropStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropStats, value.Stats, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoIpStatsResponseConverter))] public sealed partial class GeoIpStatsResponse : ElasticsearchResponse { /// @@ -33,7 +84,6 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Downloaded GeoIP2 databases for each node. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -41,6 +91,5 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Download statistics for all GeoIP2 databases. /// /// - [JsonInclude, JsonPropertyName("stats")] public Elastic.Clients.Elasticsearch.Ingest.GeoIpDownloadStatistics Stats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs index b118dfd90f7..f6208371e50 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs @@ -49,6 +49,7 @@ public sealed partial class GetGeoipDatabaseRequestParameters : RequestParameter /// public sealed partial class GetGeoipDatabaseRequest : PlainRequest { + [JsonConstructor] public GetGeoipDatabaseRequest() { } @@ -65,6 +66,16 @@ public GetGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Ids? id) : base(r = internal override string OperationName => "ingest.get_geoip_database"; + /// + /// + /// Comma-separated list of database configuration IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all database configurations, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? Id { get => P("id"); set => PO("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs index e0310e524bc..6689fae7c22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryReadProperty(ref reader, options, PropDatabases, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs index ebded8be3a5..f832dbc7682 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs @@ -49,6 +49,7 @@ public sealed partial class GetIpLocationDatabaseRequestParameters : RequestPara /// public sealed partial class GetIpLocationDatabaseRequest : PlainRequest { + [JsonConstructor] public GetIpLocationDatabaseRequest() { } @@ -65,6 +66,16 @@ public GetIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Ids? id) : bas internal override string OperationName => "ingest.get_ip_location_database"; + /// + /// + /// Comma-separated list of database configuration IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all database configurations, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? Id { get => P("id"); set => PO("id", value); } + /// /// /// The period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs index 4e185a14181..90175565b1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryReadProperty(ref reader, options, PropDatabases, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Ingest/GetPipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs index 39ca9bc7147..ca806e65857 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs @@ -57,6 +57,7 @@ public sealed partial class GetPipelineRequestParameters : RequestParameters /// public sealed partial class GetPipelineRequest : PlainRequest { + [JsonConstructor] public GetPipelineRequest() { } @@ -73,6 +74,16 @@ public GetPipelineRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Op internal override string OperationName => "ingest.get_pipeline"; + /// + /// + /// Comma-separated list of pipeline IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all ingest pipelines, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokRequest.g.cs index 32a9e9194d4..8e132c27ada 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class ProcessorGrokRequestParameters : RequestParameters /// public sealed partial class ProcessorGrokRequest : PlainRequest { + [JsonConstructor] + internal ProcessorGrokRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestProcessorGrok; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs index 823c43ea0e4..0d81e1f7796 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propPatterns = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPatterns.TryReadProperty(ref reader, options, PropPatterns, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + 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/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs index 8d0e30805a5..dc06e2cf0d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs @@ -60,6 +60,11 @@ public PutGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => { } + [JsonConstructor] + internal PutGeoipDatabaseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestPutGeoipDatabase; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -68,6 +73,14 @@ public PutGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override string OperationName => "ingest.put_geoip_database"; + /// + /// + /// ID of the database configuration to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs index 9fa354707d9..491b2e1232d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutGeoipDatabaseResponseConverter))] public sealed partial class PutGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs index 49a39028b0f..3a9ae983b93 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs @@ -51,17 +51,36 @@ public sealed partial class PutIpLocationDatabaseRequestParameters : RequestPara public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } } +internal sealed partial class PutIpLocationDatabaseRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override PutIpLocationDatabaseRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new PutIpLocationDatabaseRequest { Configuration = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIpLocationDatabaseRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Configuration, null); + } +} + /// /// /// Create or update an IP geolocation database configuration. /// /// -public sealed partial class PutIpLocationDatabaseRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(PutIpLocationDatabaseRequestConverter))] +public sealed partial class PutIpLocationDatabaseRequest : PlainRequest { public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id)) { } + [JsonConstructor] + internal PutIpLocationDatabaseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestPutIpLocationDatabase; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -70,6 +89,13 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base( internal override string OperationName => "ingest.put_ip_location_database"; + /// + /// + /// The database configuration identifier. + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The period to wait for a connection to the master node. @@ -77,7 +103,6 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base( /// A value of -1 indicates that the request should never time out. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -87,15 +112,8 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base( /// A value of -1 indicates that the request should never time out. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Ingest.DatabaseConfiguration Configuration { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Configuration, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs index 3d865e894d1..311077bf126 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIpLocationDatabaseResponseConverter))] public sealed partial class PutIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/PutPipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs index 2cf636c625b..d42c05d1045 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs @@ -66,6 +66,11 @@ public PutPipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req { } + [JsonConstructor] + internal PutPipelineRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.IngestPutPipeline; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -74,6 +79,14 @@ public PutPipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req internal override string OperationName => "ingest.put_pipeline"; + /// + /// + /// ID of the ingest pipeline to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Required version for optimistic concurrency control for pipeline updates diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs index e4f7017c4e6..bdc5b64d773 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPipelineResponseConverter))] public sealed partial class PutPipelineResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Ingest/SimulateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs index 945801158d6..4322da6a04d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs @@ -49,6 +49,7 @@ public sealed partial class SimulateRequestParameters : RequestParameters /// public sealed partial class SimulateRequest : PlainRequest { + [JsonConstructor] public SimulateRequest() { } @@ -65,6 +66,15 @@ public SimulateRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Optio internal override string OperationName => "ingest.simulate"; + /// + /// + /// Pipeline to test. + /// If you don’t specify a pipeline in the request body, this parameter is required. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// If true, the response includes output data for each processor in the executed pipeline. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs index 557e500e320..134414af7bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryReadProperty(ref reader, options, PropDocs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/LicenseManagement/DeleteLicenseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseRequest.g.cs index 4f61497c928..0b0dafd3e85 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseRequest.g.cs @@ -45,6 +45,11 @@ public sealed partial class DeleteLicenseRequestParameters : RequestParameters /// public sealed partial class DeleteLicenseRequest : PlainRequest { + [JsonConstructor] + internal DeleteLicenseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs index 91e73fcccf5..4b274a117c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class DeleteLicenseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteLicenseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteLicenseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteLicenseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLicenseResponseConverter))] public sealed partial class DeleteLicenseResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class DeleteLicenseResponse : 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/_Generated/Api/LicenseManagement/GetBasicStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusRequest.g.cs index 038af0d7d54..6baf5e76133 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusRequest.g.cs @@ -41,6 +41,11 @@ public sealed partial class GetBasicStatusRequestParameters : RequestParameters /// public sealed partial class GetBasicStatusRequest : PlainRequest { + [JsonConstructor] + internal GetBasicStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementGetBasicStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs index ec1e0cba8ff..9fc58587303 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class GetBasicStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEligibleToStartBasic = System.Text.Json.JsonEncodedText.Encode("eligible_to_start_basic"); + + public override GetBasicStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propEligibleToStartBasic = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEligibleToStartBasic.TryReadProperty(ref reader, options, PropEligibleToStartBasic, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBasicStatusResponse + { + EligibleToStartBasic = propEligibleToStartBasic.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBasicStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEligibleToStartBasic, value.EligibleToStartBasic, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBasicStatusResponseConverter))] public sealed partial class GetBasicStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("eligible_to_start_basic")] public bool EligibleToStartBasic { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseRequest.g.cs index 7cf79fc8f49..13cc18e1ea2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseRequest.g.cs @@ -52,6 +52,11 @@ public sealed partial class GetLicenseRequestParameters : RequestParameters /// public sealed partial class GetLicenseRequest : PlainRequest { + [JsonConstructor] + internal GetLicenseRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs index fae9931e751..ee25b783d8a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLicense = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLicense.TryReadProperty(ref reader, options, PropLicense, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetLicenseResponseConverter))] public sealed partial class GetLicenseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseInformation License { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusRequest.g.cs index 45d709baff7..f0899df7635 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusRequest.g.cs @@ -41,6 +41,11 @@ public sealed partial class GetTrialStatusRequestParameters : RequestParameters /// public sealed partial class GetTrialStatusRequest : PlainRequest { + [JsonConstructor] + internal GetTrialStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementGetTrialStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs index 0fa20962a0c..d739abf5f93 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class GetTrialStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEligibleToStartTrial = System.Text.Json.JsonEncodedText.Encode("eligible_to_start_trial"); + + public override GetTrialStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propEligibleToStartTrial = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEligibleToStartTrial.TryReadProperty(ref reader, options, PropEligibleToStartTrial, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrialStatusResponse + { + EligibleToStartTrial = propEligibleToStartTrial.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrialStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEligibleToStartTrial, value.EligibleToStartTrial, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrialStatusResponseConverter))] public sealed partial class GetTrialStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("eligible_to_start_trial")] public bool EligibleToStartTrial { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostRequest.g.cs index 44625e7feaa..687403c4b05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostRequest.g.cs @@ -55,6 +55,11 @@ public sealed partial class PostRequestParameters : RequestParameters /// public sealed partial class PostRequest : PlainRequest { + [JsonConstructor] + internal PostRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementPost; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs index 1ba8f7e99c6..448b8f83fb8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledge = System.Text.Json.JsonEncodedText.Encode("acknowledge"); + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropLicenseStatus = System.Text.Json.JsonEncodedText.Encode("license_status"); + + public override PostResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledge = default; + LocalJsonValue propAcknowledged = default; + LocalJsonValue propLicenseStatus = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledge.TryReadProperty(ref reader, options, PropAcknowledge, null)) + { + continue; + } + + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propLicenseStatus.TryReadProperty(ref reader, options, PropLicenseStatus, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostResponse + { + Acknowledge = propAcknowledge.Value +, + Acknowledged = propAcknowledged.Value +, + LicenseStatus = propLicenseStatus.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledge, value.Acknowledge, null, null); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropLicenseStatus, value.LicenseStatus, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostResponseConverter))] public sealed partial class PostResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledge")] public Elastic.Clients.Elasticsearch.LicenseManagement.Acknowledgement? Acknowledge { get; init; } - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("license_status")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseStatus LicenseStatus { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicRequest.g.cs index f08108f337c..a0d60df79a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicRequest.g.cs @@ -58,6 +58,11 @@ public sealed partial class PostStartBasicRequestParameters : RequestParameters /// public sealed partial class PostStartBasicRequest : PlainRequest { + [JsonConstructor] + internal PostStartBasicRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementPostStartBasic; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs index 9d33f61d74b..78617a09e7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostStartBasicResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledge = System.Text.Json.JsonEncodedText.Encode("acknowledge"); + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropBasicWasStarted = System.Text.Json.JsonEncodedText.Encode("basic_was_started"); + private static readonly System.Text.Json.JsonEncodedText PropErrorMessage = System.Text.Json.JsonEncodedText.Encode("error_message"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PostStartBasicResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>>?> propAcknowledge = default; + LocalJsonValue propAcknowledged = default; + LocalJsonValue propBasicWasStarted = default; + LocalJsonValue propErrorMessage = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledge.TryReadProperty(ref reader, options, PropAcknowledge, static IReadOnlyDictionary>>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!))) + { + continue; + } + + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propBasicWasStarted.TryReadProperty(ref reader, options, PropBasicWasStarted, null)) + { + continue; + } + + if (propErrorMessage.TryReadProperty(ref reader, options, PropErrorMessage, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostStartBasicResponse + { + Acknowledge = propAcknowledge.Value +, + Acknowledged = propAcknowledged.Value +, + BasicWasStarted = propBasicWasStarted.Value +, + ErrorMessage = propErrorMessage.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostStartBasicResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledge, value.Acknowledge, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>>? v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropBasicWasStarted, value.BasicWasStarted, null, null); + writer.WriteProperty(options, PropErrorMessage, value.ErrorMessage, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostStartBasicResponseConverter))] public sealed partial class PostStartBasicResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledge")] public IReadOnlyDictionary>>? Acknowledge { get; init; } - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("basic_was_started")] public bool BasicWasStarted { get; init; } - [JsonInclude, JsonPropertyName("error_message")] public string? ErrorMessage { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseType? Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialRequest.g.cs index e15c0abbf0f..dad2a4e430e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialRequest.g.cs @@ -56,6 +56,11 @@ public sealed partial class PostStartTrialRequestParameters : RequestParameters /// public sealed partial class PostStartTrialRequest : PlainRequest { + [JsonConstructor] + internal PostStartTrialRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.LicenseManagementPostStartTrial; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs index c95c366c974..dca89b19b9d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostStartTrialResponseConverter : 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 PropErrorMessage = System.Text.Json.JsonEncodedText.Encode("error_message"); + private static readonly System.Text.Json.JsonEncodedText PropTrialWasStarted = System.Text.Json.JsonEncodedText.Encode("trial_was_started"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PostStartTrialResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propErrorMessage = default; + LocalJsonValue propTrialWasStarted = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propErrorMessage.TryReadProperty(ref reader, options, PropErrorMessage, null)) + { + continue; + } + + if (propTrialWasStarted.TryReadProperty(ref reader, options, PropTrialWasStarted, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostStartTrialResponse + { + Acknowledged = propAcknowledged.Value +, + ErrorMessage = propErrorMessage.Value +, + TrialWasStarted = propTrialWasStarted.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostStartTrialResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropErrorMessage, value.ErrorMessage, null, null); + writer.WriteProperty(options, PropTrialWasStarted, value.TrialWasStarted, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostStartTrialResponseConverter))] public sealed partial class PostStartTrialResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("error_message")] public string? ErrorMessage { get; init; } - [JsonInclude, JsonPropertyName("trial_was_started")] public bool TrialWasStarted { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseType? Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs index d0623e3f5cf..c0fdd262596 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs @@ -49,6 +49,11 @@ public ClearTrainedModelDeploymentCacheRequest(Elastic.Clients.Elasticsearch.Id { } + [JsonConstructor] + internal ClearTrainedModelDeploymentCacheRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningClearTrainedModelDeploymentCache; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -56,6 +61,14 @@ public ClearTrainedModelDeploymentCacheRequest(Elastic.Clients.Elasticsearch.Id internal override bool SupportsBody => false; internal override string OperationName => "ml.clear_trained_model_deployment_cache"; + + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs index 8043e6d4bfa..11866918188 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCleared = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCleared.TryReadProperty(ref reader, options, PropCleared, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/CloseJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs index 57ebbdb573f..74821db131b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs @@ -49,6 +49,11 @@ public CloseJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req { } + [JsonConstructor] + internal CloseJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningCloseJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -57,6 +62,14 @@ public CloseJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.close_job"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a group name, or a wildcard expression. You can close multiple anomaly detection jobs in a single API request by using a group name, a comma-separated list of jobs, or a wildcard expression. You can close all jobs by using _all or by specifying * as the job identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs index 6548e5bf9b3..31ee1cfd663 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClosed = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClosed.TryReadProperty(ref reader, options, PropClosed, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs index c1eee87a939..06e4b5064b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs @@ -45,6 +45,11 @@ public DeleteCalendarEventRequest(Elastic.Clients.Elasticsearch.Id calendarId, E { } + [JsonConstructor] + internal DeleteCalendarEventRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteCalendarEvent; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -52,6 +57,23 @@ public DeleteCalendarEventRequest(Elastic.Clients.Elasticsearch.Id calendarId, E internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar_event"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// Identifier for the scheduled event. + /// You can obtain this identifier by using the get calendar events API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id EventId { get => P("event_id"); set => PR("event_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs index 47d28a27405..77b2ceadcee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarEventResponseConverter))] public sealed partial class DeleteCalendarEventResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs index c6365779a10..d4f8e93fbe0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs @@ -45,6 +45,11 @@ public DeleteCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Ela { } + [JsonConstructor] + internal DeleteCalendarJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteCalendarJob; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -52,6 +57,23 @@ public DeleteCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Ela internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar_job"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a + /// comma-separated list of jobs or groups. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids JobId { get => P("job_id"); set => PR("job_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs index f79e96e6c83..1b142c88c48 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryReadProperty(ref reader, options, PropCalendarId, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propJobIds.TryReadProperty(ref reader, options, PropJobIds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarJobResponseConverter))] public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,6 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +108,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/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs index e96d8a0c6fc..49e220c6557 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs @@ -46,6 +46,11 @@ public DeleteCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base { } + [JsonConstructor] + internal DeleteCalendarRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteCalendar; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,14 @@ public DeleteCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs index f2439430e4c..9b0fdd8ec76 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarResponseConverter))] public sealed partial class DeleteCalendarResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs index 0d7176897c5..ac461a9a361 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs @@ -58,6 +58,11 @@ public DeleteDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba { } + [JsonConstructor] + internal DeleteDataFrameAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteDataFrameAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -66,6 +71,14 @@ public DeleteDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "ml.delete_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// If true, it deletes a job that is not stopped; this method is quicker than stopping and deleting the job. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs index 78d91d8d7ff..a58e6268e9d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataFrameAnalyticsResponseConverter))] public sealed partial class DeleteDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs index 9d4691e39ba..dee03313c2e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs @@ -52,6 +52,11 @@ public DeleteDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base { } + [JsonConstructor] + internal DeleteDatafeedRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteDatafeed; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -60,6 +65,17 @@ public DeleteDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base internal override string OperationName => "ml.delete_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. This + /// identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It must start and end with alphanumeric + /// characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Use to forcefully delete a started datafeed; this method is quicker than diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs index 985d0ec763f..0da60387a35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDatafeedResponseConverter))] public sealed partial class DeleteDatafeedResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs index 02f49150cf5..7c5267acdcb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs @@ -49,6 +49,7 @@ public sealed partial class DeleteExpiredDataRequestParameters : RequestParamete /// public sealed partial class DeleteExpiredDataRequest : PlainRequest { + [JsonConstructor] public DeleteExpiredDataRequest() { } @@ -65,6 +66,15 @@ public DeleteExpiredDataRequest(Elastic.Clients.Elasticsearch.Id? jobId) : base( internal override string OperationName => "ml.delete_expired_data"; + /// + /// + /// Identifier for an anomaly detection job. It can be a job identifier, a + /// group name, or a wildcard expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// The desired requests per second for the deletion processes. The default diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs index 2fa4f758f7d..fb5a0c7de72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDeleted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryReadProperty(ref reader, options, PropDeleted, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs index babccd97a41..bf16332ecee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs @@ -47,6 +47,11 @@ public DeleteFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = { } + [JsonConstructor] + internal DeleteFilterRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteFilter; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -54,6 +59,14 @@ public DeleteFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_filter"; + + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs index 6d37a717058..dd70b7b9d56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteFilterResponseConverter))] public sealed partial class DeleteFilterResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs index f6ccf14951c..1868ae4bc24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs @@ -71,6 +71,11 @@ public DeleteForecastRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic.Cli { } + [JsonConstructor] + internal DeleteForecastRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteForecast; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -79,6 +84,24 @@ public DeleteForecastRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic.Cli internal override string OperationName => "ml.delete_forecast"; + /// + /// + /// A comma-separated list of forecast identifiers. If you do not specify + /// this optional parameter or if you specify _all or * the API deletes + /// all forecasts from the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? ForecastId { get => P("forecast_id"); set => PO("forecast_id", value); } + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether an error occurs when there are no forecasts. In diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs index 00b3f7ab79e..63c8b2f0195 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteForecastResponseConverter))] public sealed partial class DeleteForecastResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs index 68da0f7870a..96fe181dde3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs @@ -75,6 +75,11 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re { } + [JsonConstructor] + internal DeleteJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteJob; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -83,6 +88,14 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re internal override string OperationName => "ml.delete_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether annotations that have been added by the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs index 94765430771..67cef368c97 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteJobResponseConverter))] public sealed partial class DeleteJobResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs index 60154991bb8..0a1f16fa167 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs @@ -48,6 +48,11 @@ public DeleteModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti { } + [JsonConstructor] + internal DeleteModelSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteModelSnapshot; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -55,6 +60,22 @@ public DeleteModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_model_snapshot"; + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// Identifier for the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs index 658f9205a22..085ec764e84 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteModelSnapshotResponseConverter))] public sealed partial class DeleteModelSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs index a2802a0df4a..1c71f738764 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs @@ -48,6 +48,11 @@ public DeleteTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, { } + [JsonConstructor] + internal DeleteTrainedModelAliasRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteTrainedModelAlias; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -55,6 +60,22 @@ public DeleteTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_trained_model_alias"; + + /// + /// + /// The model alias to delete. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name ModelAlias { get => P("model_alias"); set => PR("model_alias", value); } + + /// + /// + /// The trained model ID to which the model alias refers. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs index 9d8644ff51e..52f0566c5d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelAliasResponseConverter))] public sealed partial class DeleteTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs index 11d60873725..935da14b15d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs @@ -52,6 +52,11 @@ public DeleteTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : bas { } + [JsonConstructor] + internal DeleteTrainedModelRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningDeleteTrainedModel; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -60,6 +65,14 @@ public DeleteTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : bas internal override string OperationName => "ml.delete_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Forcefully deletes a trained model that is referenced by ingest pipelines or has a started deployment. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs index 2a0564f9050..50d1e383710 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelResponseConverter))] public sealed partial class DeleteTrainedModelResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/EstimateModelMemoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryRequest.g.cs index 9ea7bd489fd..b814e91aa7e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class EstimateModelMemoryRequestParameters : RequestParame /// public sealed partial class EstimateModelMemoryRequest : PlainRequest { + [JsonConstructor] + internal EstimateModelMemoryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningEstimateModelMemory; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs index c420b7ffc87..8faba5b8159 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propModelMemoryEstimate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModelMemoryEstimate.TryReadProperty(ref reader, options, PropModelMemoryEstimate, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/EvaluateDataFrameRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameRequest.g.cs index 55715713750..ed82d301873 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameRequest.g.cs @@ -45,6 +45,11 @@ public sealed partial class EvaluateDataFrameRequestParameters : RequestParamete /// public sealed partial class EvaluateDataFrameRequest : PlainRequest { + [JsonConstructor] + internal EvaluateDataFrameRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningEvaluateDataFrame; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs index 8cad649908a..da739612e88 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClassification = default; + LocalJsonValue propOutlierDetection = default; + LocalJsonValue propRegression = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClassification.TryReadProperty(ref reader, options, PropClassification, null)) + { + continue; + } + + if (propOutlierDetection.TryReadProperty(ref reader, options, PropOutlierDetection, null)) + { + continue; + } + + if (propRegression.TryReadProperty(ref reader, options, PropRegression, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOutlierDetection, value.OutlierDetection, null, null); + writer.WriteProperty(options, PropRegression, value.Regression, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EvaluateDataFrameResponseConverter))] public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("classification")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeClassificationSummary? Classification { get; init; } - [JsonInclude, JsonPropertyName("outlier_detection")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeOutlierDetectionSummary? OutlierDetection { get; init; } - [JsonInclude, JsonPropertyName("regression")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeRegressionSummary? Regression { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs index 86ef39e34da..626e72859b1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs @@ -57,6 +57,7 @@ public sealed partial class ExplainDataFrameAnalyticsRequestParameters : Request /// public sealed partial class ExplainDataFrameAnalyticsRequest : PlainRequest { + [JsonConstructor] public ExplainDataFrameAnalyticsRequest() { } @@ -73,6 +74,16 @@ public ExplainDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.explain_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs index 9538fde34a2..b28a66247fc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propFieldSelection = default; + LocalJsonValue propMemoryEstimation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFieldSelection.TryReadProperty(ref reader, options, PropFieldSelection, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propMemoryEstimation.TryReadProperty(ref reader, options, PropMemoryEstimation, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMemoryEstimation, value.MemoryEstimation, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataFrameAnalyticsResponseConverter))] public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,7 +84,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 +91,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.MachineLearning.DataframeAnalyticsMemoryEstimation MemoryEstimation { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs index 7d2aad9a7b2..7e3ec60c917 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs @@ -53,6 +53,11 @@ public FlushJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req { } + [JsonConstructor] + internal FlushJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningFlushJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -61,6 +66,14 @@ public FlushJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.flush_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the advance_time query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs index ad4776b1c49..f76332d4280 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFlushed = default; + LocalJsonValue propLastFinalizedBucketEnd = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlushed.TryReadProperty(ref reader, options, PropFlushed, null)) + { + continue; + } + + if (propLastFinalizedBucketEnd.TryReadProperty(ref reader, options, PropLastFinalizedBucketEnd, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropLastFinalizedBucketEnd, value.LastFinalizedBucketEnd, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushJobResponseConverter))] public sealed partial class FlushJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("flushed")] public bool Flushed { get; init; } /// @@ -37,6 +87,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/_Generated/Api/MachineLearning/ForecastRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs index bfbd4285a3c..4539d29771f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs @@ -51,6 +51,11 @@ public ForecastRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req { } + [JsonConstructor] + internal ForecastRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningForecast; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -59,6 +64,15 @@ public ForecastRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.forecast"; + /// + /// + /// Identifier for the anomaly detection job. The job must be open when you + /// create a forecast; otherwise, an error occurs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the duration query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs index 90c4b0f3cb0..68d31a4969a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propForecastId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propForecastId.TryReadProperty(ref reader, options, PropForecastId, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropForecastId, value.ForecastId, null, null); + 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/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs index e24e4432ff7..fe2f0a4e851 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs @@ -63,6 +63,11 @@ public GetBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R { } + [JsonConstructor] + internal GetBucketsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetBuckets; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -71,6 +76,23 @@ public GetBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R internal override string OperationName => "ml.get_buckets"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// The timestamp of a single bucket result. If you do not specify this + /// parameter, the API returns information about all buckets. + /// + /// + [JsonIgnore] + public DateTimeOffset? Timestamp { get => P("timestamp"); set => PO("timestamp", value); } + /// /// /// Skips the specified number of buckets. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs index a4c60815b86..f7f62570609 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propBuckets = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuckets.TryReadProperty(ref reader, options, PropBuckets, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCount, value.Count, null, null); + 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/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs index 66a32155f0d..3126f1586ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs @@ -79,6 +79,11 @@ public GetCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : b { } + [JsonConstructor] + internal GetCalendarEventsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetCalendarEvents; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -87,6 +92,14 @@ public GetCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : b internal override string OperationName => "ml.get_calendar_events"; + /// + /// + /// A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using _all or * or by omitting the calendar identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// Specifies to get events with timestamps earlier than this time. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs index a8e698977df..350b71d3349 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propEvents.TryReadProperty(ref reader, options, PropEvents, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropEvents, value.Events, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs index a0ddc443b1e..c1f30cf1be0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs @@ -54,6 +54,7 @@ public sealed partial class GetCalendarsRequestParameters : RequestParameters /// public sealed partial class GetCalendarsRequest : PlainRequest { + [JsonConstructor] public GetCalendarsRequest() { } @@ -70,6 +71,14 @@ public GetCalendarsRequest(Elastic.Clients.Elasticsearch.Id? calendarId) : base( internal override string OperationName => "ml.get_calendars"; + /// + /// + /// A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using _all or * or by omitting the calendar identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? CalendarId { get => P("calendar_id"); set => PO("calendar_id", value); } + /// /// /// Skips the specified number of calendars. This parameter is supported only when you omit the calendar identifier. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs index 4b098d1cd30..8e502a5aae8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propCalendars = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendars.TryReadProperty(ref reader, options, PropCalendars, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCount, value.Count, null, null); + 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/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs index 00006ea2873..e0174627a0c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs @@ -69,6 +69,11 @@ public GetCategoriesRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => { } + [JsonConstructor] + internal GetCategoriesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetCategories; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -77,6 +82,26 @@ public GetCategoriesRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => internal override string OperationName => "ml.get_categories"; + /// + /// + /// Identifier for the category, which is unique in the job. If you specify + /// neither the category ID nor the partition_field_value, the API returns + /// information about all categories. If you specify only the + /// partition_field_value, it returns information about all categories for + /// the specified partition. + /// + /// + [JsonIgnore] + public string? CategoryId { get => P("category_id"); set => PO("category_id", value); } + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Skips the specified number of categories. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs index 0a9fef54aeb..467ed9543d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propCategories = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCategories.TryReadProperty(ref reader, options, PropCategories, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCount, value.Count, null, null); + 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/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs index 0019cb46116..70ff9cf90f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs @@ -97,6 +97,7 @@ public sealed partial class GetDataFrameAnalyticsRequestParameters : RequestPara /// public sealed partial class GetDataFrameAnalyticsRequest : PlainRequest { + [JsonConstructor] public GetDataFrameAnalyticsRequest() { } @@ -113,6 +114,16 @@ public GetDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : base internal override string OperationName => "ml.get_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. If you do not specify this + /// option, the API returns information for the first hundred data frame + /// analytics jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs index da8f94fc4cb..1bdfe35ca3a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propDataFrameAnalytics.TryReadProperty(ref reader, options, PropDataFrameAnalytics, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsResponseConverter))] public sealed partial class GetDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +86,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/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs index ee5420191c0..f79ed9dd98d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs @@ -92,6 +92,7 @@ public sealed partial class GetDataFrameAnalyticsStatsRequestParameters : Reques /// public sealed partial class GetDataFrameAnalyticsStatsRequest : PlainRequest { + [JsonConstructor] public GetDataFrameAnalyticsStatsRequest() { } @@ -108,6 +109,16 @@ public GetDataFrameAnalyticsStatsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.get_data_frame_analytics_stats"; + /// + /// + /// Identifier for the data frame analytics job. If you do not specify this + /// option, the API returns information for the first hundred data frame + /// analytics jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs index fb6b005d405..13298e1441e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propDataFrameAnalytics.TryReadProperty(ref reader, options, PropDataFrameAnalytics, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsStatsResponseConverter))] public sealed partial class GetDataFrameAnalyticsStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +86,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/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs index 12d213290c1..e61bbdc22fb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs @@ -76,6 +76,7 @@ public sealed partial class GetDatafeedStatsRequestParameters : RequestParameter /// public sealed partial class GetDatafeedStatsRequest : PlainRequest { + [JsonConstructor] public GetDatafeedStatsRequest() { } @@ -92,6 +93,16 @@ public GetDatafeedStatsRequest(Elastic.Clients.Elasticsearch.Ids? datafeedId) : internal override string OperationName => "ml.get_datafeed_stats"; + /// + /// + /// Identifier for the datafeed. It can be a datafeed identifier or a + /// wildcard expression. If you do not specify one of these options, the API + /// returns information about all datafeeds. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? DatafeedId { get => P("datafeed_id"); set => PO("datafeed_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs index 5b5b708f0f5..a8ad5451b28 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propDatafeeds.TryReadProperty(ref reader, options, PropDatafeeds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs index f4cef19baa3..5f5b0aa442c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs @@ -84,6 +84,7 @@ public sealed partial class GetDatafeedsRequestParameters : RequestParameters /// public sealed partial class GetDatafeedsRequest : PlainRequest { + [JsonConstructor] public GetDatafeedsRequest() { } @@ -100,6 +101,16 @@ public GetDatafeedsRequest(Elastic.Clients.Elasticsearch.Ids? datafeedId) : base internal override string OperationName => "ml.get_datafeeds"; + /// + /// + /// Identifier for the datafeed. It can be a datafeed identifier or a + /// wildcard expression. If you do not specify one of these options, the API + /// returns information about all datafeeds. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? DatafeedId { get => P("datafeed_id"); set => PO("datafeed_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs index 080ae74ef84..90883f6a04b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propDatafeeds.TryReadProperty(ref reader, options, PropDatafeeds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs index 0ae21abfdd6..8b2242c9dd4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs @@ -55,6 +55,7 @@ public sealed partial class GetFiltersRequestParameters : RequestParameters /// public sealed partial class GetFiltersRequest : PlainRequest { + [JsonConstructor] public GetFiltersRequest() { } @@ -71,6 +72,14 @@ public GetFiltersRequest(Elastic.Clients.Elasticsearch.Ids? filterId) : base(r = internal override string OperationName => "ml.get_filters"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? FilterId { get => P("filter_id"); set => PO("filter_id", value); } + /// /// /// Skips the specified number of filters. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs index e7c60c8592c..fd7f6f896e5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propFilters = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propFilters.TryReadProperty(ref reader, options, PropFilters, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFilters, value.Filters, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs index 5754873d0bd..06c831275f4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs @@ -109,6 +109,11 @@ public GetInfluencersRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => { } + [JsonConstructor] + internal GetInfluencersRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetInfluencers; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -117,6 +122,14 @@ public GetInfluencersRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => internal override string OperationName => "ml.get_influencers"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// If true, the results are sorted in descending order. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs index 188949c02d9..dc60a9828a1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propInfluencers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propInfluencers.TryReadProperty(ref reader, options, PropInfluencers, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropInfluencers, value.Influencers, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetInfluencersResponseConverter))] public sealed partial class GetInfluencersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +86,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/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs index bea2d642d87..eaec14bf3a9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs @@ -70,6 +70,7 @@ public sealed partial class GetJobStatsRequestParameters : RequestParameters /// public sealed partial class GetJobStatsRequest : PlainRequest { + [JsonConstructor] public GetJobStatsRequest() { } @@ -86,6 +87,17 @@ public GetJobStatsRequest(Elastic.Clients.Elasticsearch.Id? jobId) : base(r => r internal override string OperationName => "ml.get_job_stats"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, a comma-separated list of jobs, or a wildcard expression. If + /// you do not specify one of these options, the API returns information for + /// all anomaly detection jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs index 190a243cb18..7af3ff693bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propJobs.TryReadProperty(ref reader, options, PropJobs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropJobs, value.Jobs, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetJobsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs index 6d95ea6c52f..9293688ba08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs @@ -83,6 +83,7 @@ public sealed partial class GetJobsRequestParameters : RequestParameters /// public sealed partial class GetJobsRequest : PlainRequest { + [JsonConstructor] public GetJobsRequest() { } @@ -99,6 +100,16 @@ public GetJobsRequest(Elastic.Clients.Elasticsearch.Ids? jobId) : base(r => r.Op internal override string OperationName => "ml.get_jobs"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, or a wildcard expression. If you do not specify one of these + /// options, the API returns information for all anomaly detection jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs index 419693e599b..76524f70742 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propJobs.TryReadProperty(ref reader, options, PropJobs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropJobs, value.Jobs, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs index 7c8a3d1f22d..aa46f4e167b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs @@ -58,6 +58,7 @@ public sealed partial class GetMemoryStatsRequestParameters : RequestParameters /// public sealed partial class GetMemoryStatsRequest : PlainRequest { + [JsonConstructor] public GetMemoryStatsRequest() { } @@ -74,6 +75,15 @@ public GetMemoryStatsRequest(Elastic.Clients.Elasticsearch.Id? nodeId) : base(r internal override string OperationName => "ml.get_memory_stats"; + /// + /// + /// The names of particular nodes in the cluster to target. For example, nodeId1,nodeId2 or + /// ml:true + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs index ebfed58ba91..f8d84f9b7d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStatistics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStatistics.TryReadProperty(ref reader, options, PropNodeStatistics, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStatistics, value.NodeStatistics, null, null); + 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.NodeStatistics NodeStatistics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs index 2d88a9b0287..20aceedecee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs @@ -73,6 +73,11 @@ public GetModelSnapshotUpgradeStatsRequest(Elastic.Clients.Elasticsearch.Id jobI { } + [JsonConstructor] + internal GetModelSnapshotUpgradeStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetModelSnapshotUpgradeStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -81,6 +86,24 @@ public GetModelSnapshotUpgradeStatsRequest(Elastic.Clients.Elasticsearch.Id jobI internal override string OperationName => "ml.get_model_snapshot_upgrade_stats"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + /// snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using _all, + /// by specifying * as the snapshot ID, or by omitting the snapshot ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs index 45fd57704ca..627b3bc7c06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propModelSnapshotUpgrades = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propModelSnapshotUpgrades.TryReadProperty(ref reader, options, PropModelSnapshotUpgrades, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropModelSnapshotUpgrades, value.ModelSnapshotUpgrades, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs index 04ad8474205..759a991d9b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs @@ -62,6 +62,11 @@ public GetModelSnapshotsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r { } + [JsonConstructor] + internal GetModelSnapshotsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetModelSnapshots; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -70,6 +75,24 @@ public GetModelSnapshotsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r internal override string OperationName => "ml.get_model_snapshots"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + /// snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using _all, + /// by specifying * as the snapshot ID, or by omitting the snapshot ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? SnapshotId { get => P("snapshot_id"); set => PO("snapshot_id", value); } + /// /// /// Skips the specified number of snapshots. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs index b56ff39f247..5f6c83db1b3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propModelSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propModelSnapshots.TryReadProperty(ref reader, options, PropModelSnapshots, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropModelSnapshots, value.ModelSnapshots, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs index 46d90e46696..15a0947a749 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs @@ -65,6 +65,11 @@ public GetOverallBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r { } + [JsonConstructor] + internal GetOverallBucketsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetOverallBuckets; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -73,6 +78,20 @@ public GetOverallBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r internal override string OperationName => "ml.get_overall_buckets"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, a comma-separated list of jobs or groups, or a wildcard + /// expression. + /// + /// + /// You can summarize the bucket results for all anomaly detection jobs by + /// using _all or by specifying * as the <job_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs index 341db374b03..9356599e5f9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propOverallBuckets = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propOverallBuckets.TryReadProperty(ref reader, options, PropOverallBuckets, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOverallBuckets, value.OverallBuckets, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetOverallBucketsResponseConverter))] public sealed partial class GetOverallBucketsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +86,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/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs index 1fd0c64b61b..200d5fdeef3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs @@ -68,6 +68,11 @@ public GetRecordsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R { } + [JsonConstructor] + internal GetRecordsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningGetRecords; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -76,6 +81,14 @@ public GetRecordsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R internal override string OperationName => "ml.get_records"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Skips the specified number of records. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs index 10805cbe3fe..4841083075f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propRecords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propRecords.TryReadProperty(ref reader, options, PropRecords, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRecords, value.Records, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs index 3800d44371d..f4523d864ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs @@ -116,6 +116,7 @@ public sealed partial class GetTrainedModelsRequestParameters : RequestParameter /// public sealed partial class GetTrainedModelsRequest : PlainRequest { + [JsonConstructor] public GetTrainedModelsRequest() { } @@ -132,6 +133,19 @@ public GetTrainedModelsRequest(Elastic.Clients.Elasticsearch.Ids? modelId) : bas internal override string OperationName => "ml.get_trained_models"; + /// + /// + /// The unique identifier of the trained model or a model alias. + /// + /// + /// You can get information for multiple trained models in a single API + /// request by using a comma-separated list of model IDs or a wildcard + /// expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? ModelId { get => P("model_id"); set => PO("model_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs index ec971e39178..efb03545e05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propTrainedModelConfigs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTrainedModelConfigs.TryReadProperty(ref reader, options, PropTrainedModelConfigs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTrainedModelConfigs, value.TrainedModelConfigs, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsResponseConverter))] public sealed partial class GetTrainedModelsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +86,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/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs index a66c834864c..122a5401639 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs @@ -84,6 +84,7 @@ public sealed partial class GetTrainedModelsStatsRequestParameters : RequestPara /// public sealed partial class GetTrainedModelsStatsRequest : PlainRequest { + [JsonConstructor] public GetTrainedModelsStatsRequest() { } @@ -100,6 +101,15 @@ public GetTrainedModelsStatsRequest(Elastic.Clients.Elasticsearch.Ids? modelId) internal override string OperationName => "ml.get_trained_models_stats"; + /// + /// + /// The unique identifier of the trained model or a model alias. It can be a + /// comma-separated list or a wildcard expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? ModelId { get => P("model_id"); set => PO("model_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs index d49b5734363..191522608d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propTrainedModelStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTrainedModelStats.TryReadProperty(ref reader, options, PropTrainedModelStats, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTrainedModelStats, value.TrainedModelStats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsStatsResponseConverter))] public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +84,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 +91,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/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs index 79cf334a50c..8be2477871a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs @@ -51,6 +51,11 @@ public InferTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base { } + [JsonConstructor] + internal InferTrainedModelRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningInferTrainedModel; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -59,6 +64,14 @@ public InferTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base internal override string OperationName => "ml.infer_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Controls the amount of time to wait for inference results. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs index b9edc44911f..1cbeaff49ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propInferenceResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceResults.TryReadProperty(ref reader, options, PropInferenceResults, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/MlInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoRequest.g.cs index a09c2cbfe9b..204427284f5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoRequest.g.cs @@ -48,6 +48,11 @@ public sealed partial class MlInfoRequestParameters : RequestParameters /// public sealed partial class MlInfoRequest : PlainRequest { + [JsonConstructor] + internal MlInfoRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs index 7f86fd9da05..b920ff88c52 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDefaults = default; + LocalJsonValue propLimits = default; + LocalJsonValue propNativeCode = default; + LocalJsonValue propUpgradeMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryReadProperty(ref reader, options, PropDefaults, null)) + { + continue; + } + + if (propLimits.TryReadProperty(ref reader, options, PropLimits, null)) + { + continue; + } + + if (propNativeCode.TryReadProperty(ref reader, options, PropNativeCode, null)) + { + continue; + } + + if (propUpgradeMode.TryReadProperty(ref reader, options, PropUpgradeMode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropLimits, value.Limits, null, null); + writer.WriteProperty(options, PropNativeCode, value.NativeCode, null, null); + writer.WriteProperty(options, PropUpgradeMode, value.UpgradeMode, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MlInfoResponseConverter))] public sealed partial class MlInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("defaults")] public Elastic.Clients.Elasticsearch.MachineLearning.Defaults Defaults { get; init; } - [JsonInclude, JsonPropertyName("limits")] public Elastic.Clients.Elasticsearch.MachineLearning.Limits Limits { get; init; } - [JsonInclude, JsonPropertyName("native_code")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/MachineLearning/OpenJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs index b997be7d093..401b6ca89d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs @@ -51,6 +51,11 @@ public OpenJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Requ { } + [JsonConstructor] + internal OpenJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningOpenJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -59,6 +64,14 @@ public OpenJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Requ internal override string OperationName => "ml.open_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the timeout query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs index af8427ee8e5..7f7251a4287 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propNode = default; + LocalJsonValue propOpened = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryReadProperty(ref reader, options, PropNode, null)) + { + continue; + } + + if (propOpened.TryReadProperty(ref reader, options, PropOpened, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOpened, value.Opened, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenJobResponseConverter))] public sealed partial class OpenJobResponse : ElasticsearchResponse { /// @@ -34,8 +85,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/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs index 254e2fb0204..5dcec46e2e0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs @@ -45,6 +45,11 @@ public PostCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : { } + [JsonConstructor] + internal PostCalendarEventsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPostCalendarEvents; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -53,6 +58,14 @@ public PostCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : internal override string OperationName => "ml.post_calendar_events"; + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// A list of one of more scheduled events. The event’s start and end times can be specified as integer milliseconds since the epoch or as a string in ISO 8601 format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs index e8742653958..a948ecdb4ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryReadProperty(ref reader, options, PropEvents, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs index c59ce728794..01489516564 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs @@ -42,6 +42,7 @@ public sealed partial class PreviewDataFrameAnalyticsRequestParameters : Request /// public sealed partial class PreviewDataFrameAnalyticsRequest : PlainRequest { + [JsonConstructor] public PreviewDataFrameAnalyticsRequest() { } @@ -58,6 +59,14 @@ public PreviewDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.preview_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// A data frame analytics config as described in create data frame analytics diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs index 3247772bece..54b7039bea1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue>> propFeatureValues = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureValues.TryReadProperty(ref reader, options, PropFeatureValues, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PreviewDataFrameAnalyticsResponseConverter))] public sealed partial class PreviewDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs index d8286ceaee4..7a6605f3435 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs @@ -45,6 +45,11 @@ public PutCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Elasti { } + [JsonConstructor] + internal PutCalendarJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutCalendarJob; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -52,6 +57,22 @@ public PutCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Elasti internal override bool SupportsBody => false; internal override string OperationName => "ml.put_calendar_job"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a comma-separated list of jobs or groups. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids JobId { get => P("job_id"); set => PR("job_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs index 6c5d6e9ec7c..39b0c715d4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryReadProperty(ref reader, options, PropCalendarId, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propJobIds.TryReadProperty(ref reader, options, PropJobIds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarJobResponseConverter))] public sealed partial class PutCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,6 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +108,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/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs index d475637ee75..868e5331d2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs @@ -45,6 +45,11 @@ public PutCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base(r { } + [JsonConstructor] + internal PutCalendarRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutCalendar; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -53,6 +58,14 @@ public PutCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base(r internal override string OperationName => "ml.put_calendar"; + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// A description of the calendar. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs index 191a67ad6f5..8eb5c57b777 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryReadProperty(ref reader, options, PropCalendarId, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propJobIds.TryReadProperty(ref reader, options, PropJobIds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarResponseConverter))] public sealed partial class PutCalendarResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,6 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +108,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/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs index f62f35e8c15..1e01b76fffe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs @@ -47,6 +47,11 @@ public PutDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base( { } + [JsonConstructor] + internal PutDataFrameAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutDataFrameAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -55,6 +60,16 @@ public PutDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base( internal override string OperationName => "ml.put_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs index f09a4e42769..308085f9655 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs @@ -22,36 +22,184 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowLazyStart = default; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyzedFields = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propId = default; + LocalJsonValue propMaxNumThreads = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propModelMemoryLimit = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryReadProperty(ref reader, options, PropAllowLazyStart, null)) + { + continue; + } + + if (propAnalysis.TryReadProperty(ref reader, options, PropAnalysis, null)) + { + continue; + } + + if (propAnalyzedFields.TryReadProperty(ref reader, options, PropAnalyzedFields, null)) + { + continue; + } + + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propDest.TryReadProperty(ref reader, options, PropDest, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propMaxNumThreads.TryReadProperty(ref reader, options, PropMaxNumThreads, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propModelMemoryLimit.TryReadProperty(ref reader, options, PropModelMemoryLimit, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAnalysis, value.Analysis, null, null); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields, null, null); + writer.WriteProperty(options, PropAuthorization, value.Authorization, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropDest, value.Dest, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.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.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.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/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs index f73cd9f69fd..d9eab8da71e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs @@ -56,194 +56,172 @@ 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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue>>?> propHeaders = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + 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.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propHeaders.TryReadProperty(ref reader, options, PropHeaders, static IDictionary>>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!))) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null) || propIndices.TryReadProperty(ref reader, options, PropIndices1, null)) + { + continue; + } - if (value.Headers is not null) - { - writer.WritePropertyName("headers"); - JsonSerializer.Serialize(writer, value.Headers, options); - } + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropHeaders, value.Headers, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary>>? v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); writer.WriteEndObject(); } } @@ -269,7 +247,8 @@ public PutDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base(r { } - public PutDatafeedRequest() + [JsonConstructor] + internal PutDatafeedRequest() { } @@ -281,13 +260,21 @@ public PutDatafeedRequest() internal override string OperationName => "ml.put_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. + /// This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + /// It must start and end with alphanumeric characters. + /// + /// + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// If true, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the _all /// string or when no indices are specified. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -296,7 +283,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); } /// @@ -304,7 +290,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); } /// @@ -313,7 +298,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; } /// @@ -324,7 +308,6 @@ public PutDatafeedRequest() /// it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -336,7 +319,6 @@ public PutDatafeedRequest() /// This check runs only on real-time datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -348,9 +330,7 @@ public PutDatafeedRequest() /// aggregations, this value must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; set; } - [JsonInclude, JsonPropertyName("headers")] public IDictionary>>? Headers { get; set; } /// @@ -359,7 +339,6 @@ public PutDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -367,7 +346,6 @@ public PutDatafeedRequest() /// Specifies index expansion options that are used during search /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; set; } /// @@ -375,7 +353,6 @@ public PutDatafeedRequest() /// Identifier for the anomaly detection job. /// /// - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Id? JobId { get; set; } /// @@ -386,7 +363,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; } /// @@ -396,7 +372,6 @@ public PutDatafeedRequest() /// object is passed verbatim to Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -407,7 +382,6 @@ public PutDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; set; } /// @@ -415,7 +389,6 @@ public PutDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -424,7 +397,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; } /// @@ -433,7 +405,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/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs index 0a02dd03b3c..ecdc4d0eb45 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs @@ -22,40 +22,206 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propChunkingConfig.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + continue; + } + + if (propDatafeedId.TryReadProperty(ref reader, options, PropDatafeedId, null)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; + } + + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } + + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } + + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropAuthorization, value.Authorization, null, null); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); + 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.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.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.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/MachineLearning/PutFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs index 6e235f21ab1..5b63220a22f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs @@ -47,6 +47,11 @@ public PutFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r => r { } + [JsonConstructor] + internal PutFilterRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutFilter; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -55,6 +60,14 @@ public PutFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r => r internal override string OperationName => "ml.put_filter"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } + /// /// /// A description of the filter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs index 03d0bc4ab06..ed1f4c89fa9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDescription = default; + LocalJsonValue propFilterId = default; + LocalJsonValue> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propFilterId.TryReadProperty(ref reader, options, PropFilterId, null)) + { + continue; + } + + if (propItems.TryReadProperty(ref reader, options, PropItems, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFilterId, value.FilterId, null, null); + writer.WriteProperty(options, PropItems, value.Items, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/PutJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobRequest.g.cs index 7810b59710c..a07451230a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobRequest.g.cs @@ -95,6 +95,11 @@ public PutJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Requi { } + [JsonConstructor] + internal PutJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutJob; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs index cd8cb1f1ccf..7d1a8620899 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs @@ -22,50 +22,261 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowLazyOpen = default; + LocalJsonValue propAnalysisConfig = default; + LocalJsonValue propAnalysisLimits = default; + LocalJsonValue propBackgroundPersistInterval = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propCustomSettings = default; + LocalJsonValue propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonValue propDataDescription = default; + LocalJsonValue propDatafeedConfig = default; + LocalJsonValue propDescription = default; + LocalJsonValue?> propGroups = default; + LocalJsonValue propJobId = default; + LocalJsonValue propJobType = default; + LocalJsonValue propJobVersion = default; + LocalJsonValue propModelPlotConfig = default; + LocalJsonValue propModelSnapshotId = default; + LocalJsonValue propModelSnapshotRetentionDays = default; + LocalJsonValue propRenormalizationWindowDays = default; + LocalJsonValue propResultsIndexName = default; + LocalJsonValue propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryReadProperty(ref reader, options, PropAllowLazyOpen, null)) + { + continue; + } + + if (propAnalysisConfig.TryReadProperty(ref reader, options, PropAnalysisConfig, null)) + { + continue; + } + + if (propAnalysisLimits.TryReadProperty(ref reader, options, PropAnalysisLimits, null)) + { + continue; + } + + if (propBackgroundPersistInterval.TryReadProperty(ref reader, options, PropBackgroundPersistInterval, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propCustomSettings.TryReadProperty(ref reader, options, PropCustomSettings, null)) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryReadProperty(ref reader, options, PropDailyModelSnapshotRetentionAfterDays, null)) + { + continue; + } + + if (propDataDescription.TryReadProperty(ref reader, options, PropDataDescription, null)) + { + continue; + } + + if (propDatafeedConfig.TryReadProperty(ref reader, options, PropDatafeedConfig, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propGroups.TryReadProperty(ref reader, options, PropGroups, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } + + if (propJobType.TryReadProperty(ref reader, options, PropJobType, null)) + { + continue; + } + + if (propJobVersion.TryReadProperty(ref reader, options, PropJobVersion, null)) + { + continue; + } + + if (propModelPlotConfig.TryReadProperty(ref reader, options, PropModelPlotConfig, null)) + { + continue; + } + + if (propModelSnapshotId.TryReadProperty(ref reader, options, PropModelSnapshotId, null)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryReadProperty(ref reader, options, PropModelSnapshotRetentionDays, null)) + { + continue; + } + + if (propRenormalizationWindowDays.TryReadProperty(ref reader, options, PropRenormalizationWindowDays, null)) + { + continue; + } + + if (propResultsIndexName.TryReadProperty(ref reader, options, PropResultsIndexName, null)) + { + continue; + } + + if (propResultsRetentionDays.TryReadProperty(ref reader, options, PropResultsRetentionDays, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig, null, null); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits, null, null); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings, null, null); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays, null, null); + writer.WriteProperty(options, PropDataDescription, value.DataDescription, null, null); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropGroups, value.Groups, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropJobType, value.JobType, null, null); + writer.WriteProperty(options, PropJobVersion, value.JobVersion, null, null); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig, null, null); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId, null, null); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays, null, null); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays, null, null); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName, null, null); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays, null, null); + 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.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.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.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.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.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/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs index c2a8fb886fc..4167931d2d4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs @@ -69,6 +69,11 @@ public PutTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, Ela { } + [JsonConstructor] + internal PutTrainedModelAliasRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModelAlias; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -77,6 +82,22 @@ public PutTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, Ela internal override string OperationName => "ml.put_trained_model_alias"; + /// + /// + /// The alias to create or update. This value cannot end in numbers. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name ModelAlias { get => P("model_alias"); set => PR("model_alias", value); } + + /// + /// + /// The identifier for the trained model that the alias refers to. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Specifies whether the alias gets reassigned to the specified trained diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs index 0e3e893281e..ba0506526f6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelAliasResponseConverter))] public sealed partial class PutTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs index 949f8e5915c..6908f9710eb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs @@ -45,6 +45,11 @@ public PutTrainedModelDefinitionPartRequest(Elastic.Clients.Elasticsearch.Id mod { } + [JsonConstructor] + internal PutTrainedModelDefinitionPartRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModelDefinitionPart; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -53,6 +58,23 @@ public PutTrainedModelDefinitionPartRequest(Elastic.Clients.Elasticsearch.Id mod internal override string OperationName => "ml.put_trained_model_definition_part"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + + /// + /// + /// The definition part number. When the definition is loaded for inference the definition parts are streamed in the + /// order of their part number. The first part must be 0 and the final part must be total_parts - 1. + /// + /// + [JsonIgnore] + public int Part { get => P("part"); set => PR("part", value); } + /// /// /// The definition part for the model. Must be a base64 encoded string. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs index 683d8780c23..3f3d959806d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelDefinitionPartResponseConverter))] public sealed partial class PutTrainedModelDefinitionPartResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs index d5c5f91da95..35b3701b9ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs @@ -62,6 +62,11 @@ public PutTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base(r { } + [JsonConstructor] + internal PutTrainedModelRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModel; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -70,6 +75,14 @@ public PutTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base(r internal override string OperationName => "ml.put_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// If set to true and a compressed_definition is provided, diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs index cb1d77cd15a..2c56ea51380 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs @@ -22,13 +22,243 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompressedDefinition = default; + LocalJsonValue propCreatedBy = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue?> propDefaultFieldMap = default; + LocalJsonValue propDescription = default; + LocalJsonValue propEstimatedHeapMemoryUsageBytes = default; + LocalJsonValue propEstimatedOperations = default; + LocalJsonValue propFullyDefined = default; + LocalJsonValue propInferenceConfig = default; + LocalJsonValue propInput = default; + LocalJsonValue propLicenseLevel = default; + LocalJsonValue propLocation = default; + LocalJsonValue propMetadata = default; + LocalJsonValue propModelId = default; + LocalJsonValue propModelPackage = default; + LocalJsonValue propModelSizeBytes = default; + LocalJsonValue propModelType = default; + LocalJsonValue propPrefixStrings = default; + LocalJsonValue> propTags = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompressedDefinition.TryReadProperty(ref reader, options, PropCompressedDefinition, null)) + { + continue; + } + + if (propCreatedBy.TryReadProperty(ref reader, options, PropCreatedBy, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propDefaultFieldMap.TryReadProperty(ref reader, options, PropDefaultFieldMap, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propEstimatedHeapMemoryUsageBytes.TryReadProperty(ref reader, options, PropEstimatedHeapMemoryUsageBytes, null)) + { + continue; + } + + if (propEstimatedOperations.TryReadProperty(ref reader, options, PropEstimatedOperations, null)) + { + continue; + } + + if (propFullyDefined.TryReadProperty(ref reader, options, PropFullyDefined, null)) + { + continue; + } + + if (propInferenceConfig.TryReadProperty(ref reader, options, PropInferenceConfig, null)) + { + continue; + } + + if (propInput.TryReadProperty(ref reader, options, PropInput, null)) + { + continue; + } + + if (propLicenseLevel.TryReadProperty(ref reader, options, PropLicenseLevel, null)) + { + continue; + } + + if (propLocation.TryReadProperty(ref reader, options, PropLocation, null)) + { + continue; + } + + if (propMetadata.TryReadProperty(ref reader, options, PropMetadata, null)) + { + continue; + } + + if (propModelId.TryReadProperty(ref reader, options, PropModelId, null)) + { + continue; + } + + if (propModelPackage.TryReadProperty(ref reader, options, PropModelPackage, null)) + { + continue; + } + + if (propModelSizeBytes.TryReadProperty(ref reader, options, PropModelSizeBytes, null)) + { + continue; + } + + if (propModelType.TryReadProperty(ref reader, options, PropModelType, null)) + { + continue; + } + + if (propPrefixStrings.TryReadProperty(ref reader, options, PropPrefixStrings, null)) + { + continue; + } + + if (propTags.TryReadProperty(ref reader, options, PropTags, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCreatedBy, value.CreatedBy, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropDefaultFieldMap, value.DefaultFieldMap, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropEstimatedHeapMemoryUsageBytes, value.EstimatedHeapMemoryUsageBytes, null, null); + writer.WriteProperty(options, PropEstimatedOperations, value.EstimatedOperations, null, null); + writer.WriteProperty(options, PropFullyDefined, value.FullyDefined, null, null); + writer.WriteProperty(options, PropInferenceConfig, value.InferenceConfig, null, null); + writer.WriteProperty(options, PropInput, value.Input, null, null); + writer.WriteProperty(options, PropLicenseLevel, value.LicenseLevel, null, null); + writer.WriteProperty(options, PropLocation, value.Location, null, null); + writer.WriteProperty(options, PropMetadata, value.Metadata, null, null); + writer.WriteProperty(options, PropModelId, value.ModelId, null, null); + writer.WriteProperty(options, PropModelPackage, value.ModelPackage, null, null); + writer.WriteProperty(options, PropModelSizeBytes, value.ModelSizeBytes, null, null); + writer.WriteProperty(options, PropModelType, value.ModelType, null, null); + writer.WriteProperty(options, PropPrefixStrings, value.PrefixStrings, null, null); + writer.WriteProperty(options, PropTags, value.Tags, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelResponseConverter))] public sealed partial class PutTrainedModelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("compressed_definition")] public string? CompressedDefinition { get; init; } /// @@ -36,7 +266,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 +273,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 +280,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 +287,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 +294,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 +301,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 +308,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 +315,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.MachineLearning.InferenceConfigCreate? InferenceConfig { get; init; } /// @@ -100,7 +322,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The input field names for the model definition. /// /// - [JsonInclude, JsonPropertyName("input")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelConfigInput Input { get; init; } /// @@ -108,9 +329,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.MachineLearning.TrainedModelLocation? Location { get; init; } /// @@ -118,7 +337,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.MachineLearning.TrainedModelConfigMetadata? Metadata { get; init; } /// @@ -126,11 +344,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.MachineLearning.ModelPackageConfig? ModelPackage { get; init; } - [JsonInclude, JsonPropertyName("model_size_bytes")] public Elastic.Clients.Elasticsearch.ByteSize? ModelSizeBytes { get; init; } /// @@ -138,9 +353,7 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The model type /// /// - [JsonInclude, JsonPropertyName("model_type")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelType? ModelType { get; init; } - [JsonInclude, JsonPropertyName("prefix_strings")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelPrefixStrings? PrefixStrings { get; init; } /// @@ -148,7 +361,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 +368,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/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs index 410059d8e85..1ab630a3e61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs @@ -47,6 +47,11 @@ public PutTrainedModelVocabularyRequest(Elastic.Clients.Elasticsearch.Id modelId { } + [JsonConstructor] + internal PutTrainedModelVocabularyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModelVocabulary; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -55,6 +60,14 @@ public PutTrainedModelVocabularyRequest(Elastic.Clients.Elasticsearch.Id modelId internal override string OperationName => "ml.put_trained_model_vocabulary"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The optional model merges if required by the tokenizer. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs index ad429dd3de8..93a7c219378 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelVocabularyResponseConverter))] public sealed partial class PutTrainedModelVocabularyResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/ResetJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs index 22e01c4e863..cd6abc2a8af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs @@ -65,6 +65,11 @@ public ResetJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req { } + [JsonConstructor] + internal ResetJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningResetJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -73,6 +78,14 @@ public ResetJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.reset_job"; + /// + /// + /// The ID of the job to reset. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether annotations that have been added by the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs index 1376dc1be33..eda9ec6e24b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetJobResponseConverter))] public sealed partial class ResetJobResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs index fd5a431f6bc..be008ebf30a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs @@ -52,6 +52,11 @@ public RevertModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti { } + [JsonConstructor] + internal RevertModelSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningRevertModelSnapshot; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -60,6 +65,24 @@ public RevertModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override string OperationName => "ml.revert_model_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// You can specify empty as the <snapshot_id>. Reverting to the empty + /// snapshot means the anomaly detection job starts learning a new model from + /// scratch when it is started. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Refer to the description for the delete_intervening_results query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs index 845e682de52..7fdeae9301e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModel.TryReadProperty(ref reader, options, PropModel, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RevertModelSnapshotResponseConverter))] public sealed partial class RevertModelSnapshotResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("model")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeRequest.g.cs index 59688096e0e..1027abddcc1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeRequest.g.cs @@ -68,6 +68,11 @@ public sealed partial class SetUpgradeModeRequestParameters : RequestParameters /// public sealed partial class SetUpgradeModeRequest : PlainRequest { + [JsonConstructor] + internal SetUpgradeModeRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningSetUpgradeMode; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs index 2331ea78700..fff7eb306eb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SetUpgradeModeResponseConverter))] public sealed partial class SetUpgradeModeResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs index cd42cb41dfa..a1a84a91652 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs @@ -63,6 +63,11 @@ public StartDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : bas { } + [JsonConstructor] + internal StartDataFrameAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStartDataFrameAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -71,6 +76,16 @@ public StartDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : bas internal override string OperationName => "ml.start_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Controls the amount of time to wait until the data frame analytics job diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs index 2285b69b809..f91618f5ea9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propNode.TryReadProperty(ref reader, options, PropNode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNode, value.Node, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDataFrameAnalyticsResponseConverter))] public sealed partial class StartDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } /// @@ -40,6 +90,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/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs index 443127894dc..03a8d772728 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs @@ -61,6 +61,11 @@ public StartDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base( { } + [JsonConstructor] + internal StartDatafeedRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStartDatafeed; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -69,6 +74,16 @@ public StartDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base( internal override string OperationName => "ml.start_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase + /// alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric + /// characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Refer to the description for the end query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs index a8ff65cd2ea..dd712e17cfc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propNode = default; + LocalJsonValue propStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryReadProperty(ref reader, options, PropNode, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propStarted.TryReadProperty(ref reader, options, PropStarted, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStarted, value.Started, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDatafeedResponseConverter))] public sealed partial class StartDatafeedResponse : ElasticsearchResponse { /// @@ -34,8 +85,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 +92,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/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs index 81f77f7f92a..14ce1b58ac6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs @@ -113,6 +113,11 @@ public StartTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id model { } + [JsonConstructor] + internal StartTrainedModelDeploymentRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStartTrainedModelDeployment; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -121,6 +126,14 @@ public StartTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id model internal override string OperationName => "ml.start_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. Currently, only PyTorch models are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The inference cache size (in memory outside the JVM heap) per node for the model. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs index de829f86d0b..0ceb9837edd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAssignment = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAssignment.TryReadProperty(ref reader, options, PropAssignment, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTrainedModelDeploymentResponseConverter))] public sealed partial class StartTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("assignment")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelAssignment Assignment { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs index 86f9bcb4d1e..9e38615957f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs @@ -92,6 +92,11 @@ public StopDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base { } + [JsonConstructor] + internal StopDataFrameAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStopDataFrameAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -100,6 +105,16 @@ public StopDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base internal override string OperationName => "ml.stop_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs index b367f3fd569..599dcb45909 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryReadProperty(ref reader, options, PropStopped, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs index 1d8fe87c595..adfffce969d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs @@ -47,6 +47,11 @@ public StopDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base(r { } + [JsonConstructor] + internal StopDatafeedRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStopDatafeed; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -55,6 +60,16 @@ public StopDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base(r internal override string OperationName => "ml.stop_datafeed"; + /// + /// + /// Identifier for the datafeed. You can stop multiple datafeeds in a single API request by using a comma-separated + /// list of datafeeds or a wildcard expression. You can close all datafeeds by using _all or by specifying * as + /// the identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs index 984d91eafa8..21b22819f6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryReadProperty(ref reader, options, PropStopped, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs index 998d7826948..11b12dd4e55 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs @@ -62,6 +62,11 @@ public StopTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id modelI { } + [JsonConstructor] + internal StopTrainedModelDeploymentRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStopTrainedModelDeployment; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -70,6 +75,14 @@ public StopTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id modelI internal override string OperationName => "ml.stop_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Specifies what to do when the request: contains wildcard expressions and there are no deployments that match; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs index b7e839abf4f..757429a0f98 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryReadProperty(ref reader, options, PropStopped, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs index 002350b9b66..db2c27b4bee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs @@ -45,6 +45,11 @@ public UpdateDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba { } + [JsonConstructor] + internal UpdateDataFrameAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateDataFrameAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -53,6 +58,16 @@ public UpdateDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "ml.update_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs index b1c66fc047e..c6c70b1b7fd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs @@ -22,34 +22,173 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowLazyStart = default; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyzedFields = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propId = default; + LocalJsonValue propMaxNumThreads = default; + LocalJsonValue propModelMemoryLimit = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryReadProperty(ref reader, options, PropAllowLazyStart, null)) + { + continue; + } + + if (propAnalysis.TryReadProperty(ref reader, options, PropAnalysis, null)) + { + continue; + } + + if (propAnalyzedFields.TryReadProperty(ref reader, options, PropAnalyzedFields, null)) + { + continue; + } + + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propDest.TryReadProperty(ref reader, options, PropDest, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propMaxNumThreads.TryReadProperty(ref reader, options, PropMaxNumThreads, null)) + { + continue; + } + + if (propModelMemoryLimit.TryReadProperty(ref reader, options, PropModelMemoryLimit, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAnalysis, value.Analysis, null, null); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields, null, null); + writer.WriteProperty(options, PropAuthorization, value.Authorization, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropDest, value.Dest, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads, null, null); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.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.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.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/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs index b7116b1731f..b52ad419f94 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs @@ -83,182 +83,161 @@ 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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + 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.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)) || propIndices.TryReadProperty(ref reader, options, PropIndices1, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); writer.WriteEndObject(); } } @@ -279,7 +258,8 @@ public UpdateDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base { } - public UpdateDatafeedRequest() + [JsonConstructor] + internal UpdateDatafeedRequest() { } @@ -291,13 +271,21 @@ public UpdateDatafeedRequest() internal override string OperationName => "ml.update_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. + /// This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + /// It must start and end with alphanumeric characters. + /// + /// + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// If true, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the /// _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 +321,6 @@ public UpdateDatafeedRequest() /// /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -341,7 +328,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 +336,6 @@ public UpdateDatafeedRequest() /// with low cardinality data. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -360,7 +345,6 @@ public UpdateDatafeedRequest() /// these time chunks are calculated; it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -372,7 +356,6 @@ public UpdateDatafeedRequest() /// datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -384,7 +367,6 @@ public UpdateDatafeedRequest() /// must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; set; } /// @@ -393,7 +375,6 @@ public UpdateDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public ICollection? Indices { get; set; } /// @@ -401,9 +382,7 @@ public UpdateDatafeedRequest() /// Specifies index expansion options that are used during search. /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; set; } - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Id? JobId { get; set; } /// @@ -414,7 +393,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 +406,6 @@ public UpdateDatafeedRequest() /// when you are satisfied with the results of the job. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -439,7 +416,6 @@ public UpdateDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; set; } /// @@ -447,7 +423,6 @@ public UpdateDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -456,7 +431,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 +439,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/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs index ebee97ee8e8..18c2d800c12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs @@ -22,40 +22,206 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propChunkingConfig.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + continue; + } + + if (propDatafeedId.TryReadProperty(ref reader, options, PropDatafeedId, null)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; + } + + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } + + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } + + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropAuthorization, value.Authorization, null, null); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); + 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.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.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.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs index 444d8a9d5a7..3455bdee7a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs @@ -46,6 +46,11 @@ public UpdateFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = { } + [JsonConstructor] + internal UpdateFilterRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateFilter; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,14 @@ public UpdateFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = internal override string OperationName => "ml.update_filter"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } + /// /// /// The items to add to the filter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs index 7cbe0f06cbc..90469cc89de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDescription = default; + LocalJsonValue propFilterId = default; + LocalJsonValue> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propFilterId.TryReadProperty(ref reader, options, PropFilterId, null)) + { + continue; + } + + if (propItems.TryReadProperty(ref reader, options, PropItems, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFilterId, value.FilterId, null, null); + writer.WriteProperty(options, PropItems, value.Items, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs index 83f7061f442..a1ace49d68c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs @@ -46,6 +46,11 @@ public UpdateJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re { } + [JsonConstructor] + internal UpdateJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,14 @@ public UpdateJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re internal override string OperationName => "ml.update_job"; + /// + /// + /// Identifier for the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Advanced configuration option. Specifies whether this job can open when diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs index 0fbf50d92cd..9c4e6fa1d97 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs @@ -22,52 +22,272 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowLazyOpen = default; + LocalJsonValue propAnalysisConfig = default; + LocalJsonValue propAnalysisLimits = default; + LocalJsonValue propBackgroundPersistInterval = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue?> propCustomSettings = default; + LocalJsonValue propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonValue propDataDescription = default; + LocalJsonValue propDatafeedConfig = default; + LocalJsonValue propDescription = default; + LocalJsonValue propFinishedTime = default; + LocalJsonValue?> propGroups = default; + LocalJsonValue propJobId = default; + LocalJsonValue propJobType = default; + LocalJsonValue propJobVersion = default; + LocalJsonValue propModelPlotConfig = default; + LocalJsonValue propModelSnapshotId = default; + LocalJsonValue propModelSnapshotRetentionDays = default; + LocalJsonValue propRenormalizationWindowDays = default; + LocalJsonValue propResultsIndexName = default; + LocalJsonValue propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryReadProperty(ref reader, options, PropAllowLazyOpen, null)) + { + continue; + } + + if (propAnalysisConfig.TryReadProperty(ref reader, options, PropAnalysisConfig, null)) + { + continue; + } + + if (propAnalysisLimits.TryReadProperty(ref reader, options, PropAnalysisLimits, null)) + { + continue; + } + + if (propBackgroundPersistInterval.TryReadProperty(ref reader, options, PropBackgroundPersistInterval, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propCustomSettings.TryReadProperty(ref reader, options, PropCustomSettings, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryReadProperty(ref reader, options, PropDailyModelSnapshotRetentionAfterDays, null)) + { + continue; + } + + if (propDataDescription.TryReadProperty(ref reader, options, PropDataDescription, null)) + { + continue; + } + + if (propDatafeedConfig.TryReadProperty(ref reader, options, PropDatafeedConfig, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propFinishedTime.TryReadProperty(ref reader, options, PropFinishedTime, null)) + { + continue; + } + + if (propGroups.TryReadProperty(ref reader, options, PropGroups, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } + + if (propJobType.TryReadProperty(ref reader, options, PropJobType, null)) + { + continue; + } + + if (propJobVersion.TryReadProperty(ref reader, options, PropJobVersion, null)) + { + continue; + } + + if (propModelPlotConfig.TryReadProperty(ref reader, options, PropModelPlotConfig, null)) + { + continue; + } + + if (propModelSnapshotId.TryReadProperty(ref reader, options, PropModelSnapshotId, null)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryReadProperty(ref reader, options, PropModelSnapshotRetentionDays, null)) + { + continue; + } + + if (propRenormalizationWindowDays.TryReadProperty(ref reader, options, PropRenormalizationWindowDays, null)) + { + continue; + } + + if (propResultsIndexName.TryReadProperty(ref reader, options, PropResultsIndexName, null)) + { + continue; + } + + if (propResultsRetentionDays.TryReadProperty(ref reader, options, PropResultsRetentionDays, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig, null, null); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits, null, null); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays, null, null); + writer.WriteProperty(options, PropDataDescription, value.DataDescription, null, null); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropFinishedTime, value.FinishedTime, null, null); + writer.WriteProperty(options, PropGroups, value.Groups, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropJobType, value.JobType, null, null); + writer.WriteProperty(options, PropJobVersion, value.JobVersion, null, null); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig, null, null); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId, null, null); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays, null, null); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays, null, null); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName, null, null); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays, null, null); + 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.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.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.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.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.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/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs index d8c88bacb00..5bfc2e6309f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs @@ -46,6 +46,11 @@ public UpdateModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti { } + [JsonConstructor] + internal UpdateModelSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateModelSnapshot; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,22 @@ public UpdateModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override string OperationName => "ml.update_model_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// Identifier for the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// A description of the model snapshot. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs index c5fb4fc4670..6460c26d0ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propModel.TryReadProperty(ref reader, options, PropModel, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropModel, value.Model, null, null); + 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.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs index fbbf728cec4..6464eabbaf1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs @@ -45,6 +45,11 @@ public UpdateTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id mode { } + [JsonConstructor] + internal UpdateTrainedModelDeploymentRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateTrainedModelDeployment; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -53,6 +58,14 @@ public UpdateTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id mode internal override string OperationName => "ml.update_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. Currently, only PyTorch models are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The number of model allocations on each node where the model is deployed. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs index 3ef93e48077..781d3d39b56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAssignment = System.Text.Json.JsonEncodedText.Encode("assignment"); + + public override UpdateTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAssignment = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAssignment.TryReadProperty(ref reader, options, PropAssignment, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateTrainedModelDeploymentResponse + { + Assignment = propAssignment.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAssignment, value.Assignment, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateTrainedModelDeploymentResponseConverter))] public sealed partial class UpdateTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("assignment")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelAssignment Assignment { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs index 07886ed234a..e1abf32768f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs @@ -68,6 +68,11 @@ public UpgradeJobSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic { } + [JsonConstructor] + internal UpgradeJobSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpgradeJobSnapshot; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -76,6 +81,22 @@ public UpgradeJobSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic internal override string OperationName => "ml.upgrade_job_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Controls the time to wait for the request to complete. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs index 95e29dedea5..f2744747ae1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompleted = default; + LocalJsonValue propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompleted.TryReadProperty(ref reader, options, PropCompleted, null)) + { + continue; + } + + if (propNode.TryReadProperty(ref reader, options, PropNode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNode, value.Node, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeJobSnapshotResponseConverter))] public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +84,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 +91,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/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs index 0d1a079f90b..1ff029b4761 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs @@ -34,13 +34,32 @@ public sealed partial class ValidateDetectorRequestParameters : RequestParameter { } +internal sealed partial class ValidateDetectorRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override ValidateDetectorRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new ValidateDetectorRequest { Detector = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateDetectorRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Detector, null); + } +} + /// /// /// Validate an anomaly detection job. /// /// -public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(ValidateDetectorRequestConverter))] +public sealed partial class ValidateDetectorRequest : PlainRequest { + [JsonConstructor] + internal ValidateDetectorRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidateDetector; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -49,13 +68,7 @@ public sealed partial class ValidateDetectorRequest : PlainRequest "ml.validate_detector"; - [JsonIgnore] public Elastic.Clients.Elasticsearch.MachineLearning.Detector Detector { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Detector, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs index 3b016da7f28..7b4aa3fdbb5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateDetectorResponseConverter))] public sealed partial class ValidateDetectorResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MachineLearning/ValidateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateRequest.g.cs index 2f532c21c40..ef8f1fa3b0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateRequest.g.cs @@ -41,6 +41,11 @@ public sealed partial class ValidateRequestParameters : RequestParameters /// public sealed partial class ValidateRequest : PlainRequest { + [JsonConstructor] + internal ValidateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs index 09bd6cb03b7..3a72841a07d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateResponseConverter))] public sealed partial class ValidateResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/MultiGetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs index 192b345d954..550376edff8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs @@ -113,6 +113,7 @@ public sealed partial class MultiGetRequestParameters : RequestParameters /// public sealed partial class MultiGetRequest : PlainRequest { + [JsonConstructor] public MultiGetRequest() { } @@ -129,6 +130,14 @@ public MultiGetRequest(Elastic.Clients.Elasticsearch.IndexName? index) : base(r internal override string OperationName => "mget"; + /// + /// + /// Name of the index to retrieve documents from when ids are specified, or when a document in the docs array does not specify an index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// Should this request force synthetic _source? diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs index 13199e2f0a7..c019cfd9e31 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs @@ -22,12 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue>> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryReadProperty(ref reader, options, PropDocs, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + 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/_Generated/Api/MultiSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs index 526b27fa61e..e3aecc47c82 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs @@ -142,8 +142,9 @@ public sealed partial class MultiSearchRequestParameters : RequestParameters /// When sending requests to this endpoint the Content-Type header should be set to application/x-ndjson. /// /// -public sealed partial class MultiSearchRequest : PlainRequest, IStreamSerializable +public sealed partial class MultiSearchRequest : PlainRequest { + [JsonConstructor] public MultiSearchRequest() { } @@ -160,6 +161,14 @@ public MultiSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base internal override string OperationName => "msearch"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases to search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. @@ -256,28 +265,6 @@ public MultiSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } public List Searches { get; set; } - - void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting) - { - if (Searches is null) - return; - foreach (var item in Searches) - { - if (item is IStreamSerializable serializable) - serializable.Serialize(stream, settings, formatting); - } - } - - async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting) - { - if (Searches is null) - return; - foreach (var item in Searches) - { - if (item is IStreamSerializable serializable) - await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false); - } - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs index a942a757900..93788c88280 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs @@ -22,14 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue>> propResponses = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryReadProperty(ref reader, options, PropResponses, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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/_Generated/Api/MultiSearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs index 2c558db006d..28d8948facd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs @@ -77,8 +77,9 @@ public sealed partial class MultiSearchTemplateRequestParameters : RequestParame /// Run multiple templated searches. /// /// -public sealed partial class MultiSearchTemplateRequest : PlainRequest, IStreamSerializable +public sealed partial class MultiSearchTemplateRequest : PlainRequest { + [JsonConstructor] public MultiSearchTemplateRequest() { } @@ -95,6 +96,16 @@ public MultiSearchTemplateRequest(Elastic.Clients.Elasticsearch.Indices? indices internal override string OperationName => "msearch_template"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If true, network round-trips are minimized for cross-cluster search requests. @@ -137,28 +148,6 @@ public MultiSearchTemplateRequest(Elastic.Clients.Elasticsearch.Indices? indices [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } public List SearchTemplates { get; set; } - - void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting) - { - if (SearchTemplates is null) - return; - foreach (var item in SearchTemplates) - { - if (item is IStreamSerializable serializable) - serializable.Serialize(stream, settings, formatting); - } - } - - async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting) - { - if (SearchTemplates is null) - return; - foreach (var item in SearchTemplates) - { - if (item is IStreamSerializable serializable) - await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false); - } - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs index 061ee312555..e5e35c6aae7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs @@ -22,14 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue>> propResponses = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryReadProperty(ref reader, options, PropResponses, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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/_Generated/Api/MultiTermVectorsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs index 9a6c3ba7206..27f4e8cacea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs @@ -125,6 +125,7 @@ public sealed partial class MultiTermVectorsRequestParameters : RequestParameter /// public sealed partial class MultiTermVectorsRequest : PlainRequest { + [JsonConstructor] public MultiTermVectorsRequest() { } @@ -141,6 +142,14 @@ public MultiTermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName? index) : internal override string OperationName => "mtermvectors"; + /// + /// + /// Name of the index that contains the documents. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in the statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs index 36c309f3cab..d3ad3c66494 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryReadProperty(ref reader, options, PropDocs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs index bd81ff113e0..457c766d33f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs @@ -46,6 +46,11 @@ public ClearRepositoriesMeteringArchiveRequest(Elastic.Clients.Elasticsearch.Nod { } + [JsonConstructor] + internal ClearRepositoriesMeteringArchiveRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NodesClearRepositoriesMeteringArchive; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,23 @@ public ClearRepositoriesMeteringArchiveRequest(Elastic.Clients.Elasticsearch.Nod internal override bool SupportsBody => false; internal override string OperationName => "nodes.clear_repositories_metering_archive"; + + /// + /// + /// Specifies the maximum archive_version to be cleared from the archive. + /// + /// + [JsonIgnore] + public long MaxArchiveVersion { get => P("max_archive_version"); set => PR("max_archive_version", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// All the nodes selective options are explained here. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds NodeId { get => P("node_id"); set => PR("node_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs index 5b20e33dca1..4f2f103419e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class ClearRepositoriesMeteringArchiveResponseConverter : 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 ClearRepositoriesMeteringArchiveResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearRepositoriesMeteringArchiveResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearRepositoriesMeteringArchiveResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearRepositoriesMeteringArchiveResponseConverter))] public sealed partial class ClearRepositoriesMeteringArchiveResponse : ElasticsearchResponse { /// @@ -33,7 +94,6 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Name of the cluster. Based on the Cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +101,6 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Contains repositories metering information for the nodes selected by the request. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -49,6 +108,5 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs index 58ce8fee68b..b807e63a6b3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs @@ -48,6 +48,11 @@ public GetRepositoriesMeteringInfoRequest(Elastic.Clients.Elasticsearch.NodeIds { } + [JsonConstructor] + internal GetRepositoriesMeteringInfoRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NodesGetRepositoriesMeteringInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -55,6 +60,15 @@ public GetRepositoriesMeteringInfoRequest(Elastic.Clients.Elasticsearch.NodeIds internal override bool SupportsBody => false; internal override string OperationName => "nodes.get_repositories_metering_info"; + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// All the nodes selective options are explained here. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds NodeId { get => P("node_id"); set => PR("node_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs index 5699dc4d2fb..6ae516950ce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class GetRepositoriesMeteringInfoResponseConverter : 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 GetRepositoriesMeteringInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRepositoriesMeteringInfoResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRepositoriesMeteringInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRepositoriesMeteringInfoResponseConverter))] public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchResponse { /// @@ -33,7 +94,6 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Name of the cluster. Based on the Cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +101,6 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Contains repositories metering information for the nodes selected by the request. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -49,6 +108,5 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs index 0f6987065fc..875b805c3bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs @@ -102,6 +102,7 @@ public sealed partial class HotThreadsRequestParameters : RequestParameters /// public sealed partial class HotThreadsRequest : PlainRequest { + [JsonConstructor] public HotThreadsRequest() { } @@ -118,6 +119,14 @@ public HotThreadsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base(r internal override string OperationName => "nodes.hot_threads"; + /// + /// + /// List of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// If true, known idle threads (e.g. waiting in a socket select, or to get diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs index f1677d7d5c5..b656873df7b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs @@ -22,10 +22,39 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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) + { + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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/_Generated/Api/Nodes/NodesInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs index 104b1f5333f..718080a860b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs @@ -62,6 +62,7 @@ public sealed partial class NodesInfoRequestParameters : RequestParameters /// public sealed partial class NodesInfoRequest : PlainRequest { + [JsonConstructor] public NodesInfoRequest() { } @@ -86,6 +87,22 @@ public NodesInfoRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic.C internal override string OperationName => "nodes.info"; + /// + /// + /// Limits the information returned to the specific metrics. Supports a comma-separated list, such as http,ingest. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs index 5ca252fad2f..5faf92a67fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs @@ -22,15 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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 +97,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.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs index 47a0483057f..eb005a81ddd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs @@ -112,6 +112,7 @@ public sealed partial class NodesStatsRequestParameters : RequestParameters /// public sealed partial class NodesStatsRequest : PlainRequest { + [JsonConstructor] public NodesStatsRequest() { } @@ -144,6 +145,30 @@ public NodesStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic. internal override string OperationName => "nodes.stats"; + /// + /// + /// Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? IndexMetric { get => P("index_metric"); set => PO("index_metric", value); } + + /// + /// + /// Limit the information returned to the specified metrics + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs index cb917ccc1c0..5fcbe99a3dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs @@ -22,15 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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 +97,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.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs index 28adaf7a654..889d1e7c561 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs @@ -48,6 +48,7 @@ public sealed partial class NodesUsageRequestParameters : RequestParameters /// public sealed partial class NodesUsageRequest : PlainRequest { + [JsonConstructor] public NodesUsageRequest() { } @@ -72,6 +73,23 @@ public NodesUsageRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic. internal override string OperationName => "nodes.usage"; + /// + /// + /// Limits the information returned to the specific metrics. + /// A comma-separated list of the following options: _all, rest_actions. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you're connecting to, leave empty to get information from all nodes + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs index daaa410f471..35c099a00ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs @@ -22,15 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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 +97,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.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs index 5e944e764a9..d0830daff00 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs @@ -58,6 +58,7 @@ public sealed partial class ReloadSecureSettingsRequestParameters : RequestParam /// public sealed partial class ReloadSecureSettingsRequest : PlainRequest { + [JsonConstructor] public ReloadSecureSettingsRequest() { } @@ -74,6 +75,14 @@ public ReloadSecureSettingsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId internal override string OperationName => "nodes.reload_secure_settings"; + /// + /// + /// The names of particular nodes in the cluster to target. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs index 0ad2ae88554..f895ca0bb7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs @@ -22,15 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class ReloadSecureSettingsResponseConverter : 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 ReloadSecureSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReloadSecureSettingsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReloadSecureSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReloadSecureSettingsResponseConverter))] public sealed partial class ReloadSecureSettingsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +97,5 @@ public sealed partial class ReloadSecureSettingsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs index 4741472e4d9..a889c7cd7eb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs @@ -102,6 +102,11 @@ public OpenPointInTimeRequest(Elastic.Clients.Elasticsearch.Indices indices) : b { } + [JsonConstructor] + internal OpenPointInTimeRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceOpenPointInTime; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -110,6 +115,14 @@ public OpenPointInTimeRequest(Elastic.Clients.Elasticsearch.Indices indices) : b internal override string OperationName => "open_point_in_time"; + /// + /// + /// A comma-separated list of index names to open point in time; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, creating a point in time request when a shard is missing or unavailable will throw an exception. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs index 1dd4dd1105d..91c7498ca15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs @@ -22,13 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propId = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenPointInTimeResponseConverter))] public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -36,6 +86,5 @@ public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse /// Shards used to create the PIT /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PingRequest.g.cs index 34182e1e3e2..56548f682e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PingRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class PingRequestParameters : RequestParameters /// public sealed partial class PingRequest : PlainRequest { + [JsonConstructor] + internal PingRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespacePing; protected override HttpMethod StaticHttpMethod => HttpMethod.HEAD; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs index 91d6b99e3cf..068ca14b48c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs @@ -65,6 +65,11 @@ public PutScriptRequest(Elastic.Clients.Elasticsearch.Id id, Elastic.Clients.Ela { } + [JsonConstructor] + internal PutScriptRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespacePutScript; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -73,6 +78,24 @@ public PutScriptRequest(Elastic.Clients.Elasticsearch.Id id, Elastic.Clients.Ela internal override string OperationName => "put_script"; + /// + /// + /// Context in which the script or search template should run. + /// To prevent errors, the API immediately compiles the script or template in this context. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Context { get => P("context"); set => PO("context", value); } + + /// + /// + /// Identifier for the stored script or search template. + /// Must be unique within the cluster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs index 7b863a48caa..9047e9b5ff1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutScriptResponseConverter))] public sealed partial class PutScriptResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs index 5db5e648058..5e103aafc4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs @@ -46,6 +46,11 @@ public DeleteRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Cli { } + [JsonConstructor] + internal DeleteRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesDeleteRule; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,22 @@ public DeleteRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Cli internal override bool SupportsBody => false; internal override string OperationName => "query_rules.delete_rule"; + + /// + /// + /// The unique identifier of the query rule within the specified ruleset to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs index cd36153036e..b104264c291 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRuleResponseConverter))] public sealed partial class DeleteRuleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs index c9ff402c290..796ad56bdce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs @@ -45,6 +45,11 @@ public DeleteRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r { } + [JsonConstructor] + internal DeleteRulesetRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesDeleteRuleset; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -52,6 +57,14 @@ public DeleteRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r internal override bool SupportsBody => false; internal override string OperationName => "query_rules.delete_ruleset"; + + /// + /// + /// The unique identifier of the query ruleset to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs index eb6ccc13ee9..61d84c020f7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRulesetResponseConverter))] public sealed partial class DeleteRulesetResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/QueryRules/GetRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs index 947016c599d..ece67a14c1d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs @@ -46,6 +46,11 @@ public GetRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Client { } + [JsonConstructor] + internal GetRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesGetRule; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,22 @@ public GetRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Client internal override bool SupportsBody => false; internal override string OperationName => "query_rules.get_rule"; + + /// + /// + /// The unique identifier of the query rule within the specified ruleset to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs index 014f75a2f0f..bb9f1cd63e7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs @@ -22,21 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propRuleId = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryReadProperty(ref reader, options, PropActions, null)) + { + continue; + } + + if (propCriteria.TryReadProperty(ref reader, options, PropCriteria, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } + + if (propRuleId.TryReadProperty(ref reader, options, PropRuleId, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropRuleId, value.RuleId, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRuleResponseConverter))] public sealed partial class GetRuleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; init; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public IReadOnlyCollection Criteria { get; init; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; init; } - [JsonInclude, JsonPropertyName("rule_id")] public string RuleId { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs index 2241fbfbab8..a30de541568 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs @@ -46,6 +46,11 @@ public GetRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => { } + [JsonConstructor] + internal GetRulesetRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesGetRuleset; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,14 @@ public GetRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "query_rules.get_ruleset"; + + /// + /// + /// The unique identifier of the query ruleset + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs index c0fef19badb..5c7cb9f4bce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propRules = default; + LocalJsonValue propRulesetId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryReadProperty(ref reader, options, PropRules, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propRulesetId.TryReadProperty(ref reader, options, PropRulesetId, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRulesetId, value.RulesetId, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRulesetResponseConverter))] public sealed partial class GetRulesetResponse : ElasticsearchResponse { /// @@ -33,7 +84,6 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// Rules associated with the query ruleset /// /// - [JsonInclude, JsonPropertyName("rules")] public IReadOnlyCollection Rules { get; init; } /// @@ -41,6 +91,5 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// Query Ruleset unique identifier /// /// - [JsonInclude, JsonPropertyName("ruleset_id")] public string RulesetId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsRequest.g.cs index 1c0b5e1be87..7602765415f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsRequest.g.cs @@ -55,6 +55,11 @@ public sealed partial class ListRulesetsRequestParameters : RequestParameters /// public sealed partial class ListRulesetsRequest : PlainRequest { + [JsonConstructor] + internal ListRulesetsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesListRulesets; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs index dc7e677080a..7159b110213 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propResults.TryReadProperty(ref reader, options, PropResults, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropResults, value.Results, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/QueryRules/PutRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs index b9287c5cda7..fa1f1dce11b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs @@ -34,18 +34,92 @@ 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); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryReadProperty(ref reader, options, PropActions, null)) + { + continue; + } + + if (propCriteria.TryReadProperty(ref reader, options, PropCriteria, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query rule. /// Create or update a query rule within a query ruleset. /// /// +[JsonConverter(typeof(PutRuleRequestConverter))] public sealed partial class PutRuleRequest : PlainRequest { public PutRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Clients.Elasticsearch.Id ruleId) : base(r => r.Required("ruleset_id", rulesetId).Required("rule_id", ruleId)) { } + [JsonConstructor] + internal PutRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesPutRule; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -54,14 +128,22 @@ public PutRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Client internal override string OperationName => "query_rules.put_rule"; - [JsonInclude, JsonPropertyName("actions")] + /// + /// + /// The unique identifier of the query rule within the specified ruleset to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; set; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs index b0df637361d..30bd4841476 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRuleResponseConverter))] public sealed partial class PutRuleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs index 3d91b4e2890..1a3c6548ad4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs @@ -34,17 +34,61 @@ 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); + LocalJsonValue> propRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryReadProperty(ref reader, options, PropRules, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query ruleset. /// /// +[JsonConverter(typeof(PutRulesetRequestConverter))] public sealed partial class PutRulesetRequest : PlainRequest { public PutRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => r.Required("ruleset_id", rulesetId)) { } + [JsonConstructor] + internal PutRulesetRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesPutRuleset; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -53,8 +97,12 @@ public PutRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => internal override string OperationName => "query_rules.put_ruleset"; - [JsonInclude, JsonPropertyName("rules")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRule))] + /// + /// + /// The unique identifier of the query ruleset to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } public ICollection Rules { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs index 23c35068711..06e0bd2f4ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRulesetResponseConverter))] public sealed partial class PutRulesetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs index 973d126cfdb..19ffaa51950 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs @@ -46,6 +46,11 @@ public TestRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => r.Req { } + [JsonConstructor] + internal TestRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.QueryRulesTest; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,13 @@ public TestRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => r.Req internal override string OperationName => "query_rules.test"; + /// + /// + /// The unique identifier of the query ruleset to be created or updated + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } [JsonInclude, JsonPropertyName("match_criteria")] public IDictionary MatchCriteria { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs index 6afa8a862e7..97aab74fc7b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propMatchedRules = default; + LocalJsonValue propTotalMatchedRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatchedRules.TryReadProperty(ref reader, options, PropMatchedRules, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTotalMatchedRules.TryReadProperty(ref reader, options, PropTotalMatchedRules, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTotalMatchedRules, value.TotalMatchedRules, null, null); + 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/_Generated/Api/RankEvalRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs index c42ede2ec90..845756859af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs @@ -71,6 +71,7 @@ public sealed partial class RankEvalRequestParameters : RequestParameters /// public sealed partial class RankEvalRequest : PlainRequest { + [JsonConstructor] public RankEvalRequest() { } @@ -87,6 +88,15 @@ public RankEvalRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "rank_eval"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard (*) expressions are supported. + /// To target all data streams and indices in a cluster, omit this parameter or use _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs index c8fffdd414c..22754430d83 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue> propDetails = default; + LocalJsonValue> propFailures = default; + LocalJsonValue propMetricScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetails.TryReadProperty(ref reader, options, PropDetails, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propFailures.TryReadProperty(ref reader, options, PropFailures, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propMetricScore.TryReadProperty(ref reader, options, PropMetricScore, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFailures, value.Failures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropMetricScore, value.MetricScore, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalResponseConverter))] public sealed partial class RankEvalResponse : ElasticsearchResponse { /// @@ -33,9 +94,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 +102,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/_Generated/Api/ReindexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRequest.g.cs index fa7c00a14bd..fb8c4a1ea31 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRequest.g.cs @@ -100,6 +100,11 @@ public sealed partial class ReindexRequestParameters : RequestParameters /// public sealed partial class ReindexRequest : PlainRequest { + [JsonConstructor] + internal ReindexRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceReindex; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs index 615f5821c06..a9acf08fff7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs @@ -22,42 +22,217 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propBatches = default; + LocalJsonValue propCreated = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propSliceId = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propUpdated = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryReadProperty(ref reader, options, PropBatches, null)) + { + continue; + } + + if (propCreated.TryReadProperty(ref reader, options, PropCreated, null)) + { + continue; + } + + if (propDeleted.TryReadProperty(ref reader, options, PropDeleted, null)) + { + continue; + } + + if (propFailures.TryReadProperty(ref reader, options, PropFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNoops.TryReadProperty(ref reader, options, PropNoops, null)) + { + continue; + } + + if (propRequestsPerSecond.TryReadProperty(ref reader, options, PropRequestsPerSecond, null)) + { + continue; + } + + if (propRetries.TryReadProperty(ref reader, options, PropRetries, null)) + { + continue; + } + + if (propSliceId.TryReadProperty(ref reader, options, PropSliceId, null)) + { + continue; + } + + if (propTask.TryReadProperty(ref reader, options, PropTask, null)) + { + continue; + } + + if (propThrottledMillis.TryReadProperty(ref reader, options, PropThrottledMillis, null)) + { + continue; + } + + if (propThrottledUntilMillis.TryReadProperty(ref reader, options, PropThrottledUntilMillis, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, null)) + { + continue; + } + + if (propVersionConflicts.TryReadProperty(ref reader, options, PropVersionConflicts, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCreated, value.Created, null, null); + writer.WriteProperty(options, PropDeleted, value.Deleted, null, null); + writer.WriteProperty(options, PropFailures, value.Failures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNoops, value.Noops, null, null); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond, null, null); + writer.WriteProperty(options, PropRetries, value.Retries, null, null); + writer.WriteProperty(options, PropSliceId, value.SliceId, null, null); + writer.WriteProperty(options, PropTask, value.Task, null, null); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis, null, null); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteProperty(options, PropUpdated, value.Updated, null, null); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts, null, null); + 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.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/ReindexRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs index 88bf92f8d80..230d1cd74c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs @@ -54,6 +54,11 @@ public ReindexRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : base( { } + [JsonConstructor] + internal ReindexRethrottleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceReindexRethrottle; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -62,6 +67,14 @@ public ReindexRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : base( internal override string OperationName => "reindex_rethrottle"; + /// + /// + /// Identifier for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs index eb0a0d689a5..a85d82b0648 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + 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/_Generated/Api/RenderSearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs index 26361bc0ec5..fb7768d325d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs @@ -44,6 +44,7 @@ public sealed partial class RenderSearchTemplateRequestParameters : RequestParam /// public sealed partial class RenderSearchTemplateRequest : PlainRequest { + [JsonConstructor] public RenderSearchTemplateRequest() { } @@ -60,6 +61,14 @@ public RenderSearchTemplateRequest(Elastic.Clients.Elasticsearch.Id? id) : base( internal override string OperationName => "render_search_template"; + /// + /// + /// ID of the search template to render. + /// If no source is specified, this or the id request body parameter is required. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } [JsonInclude, JsonPropertyName("file")] public string? File { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs index 9fba7ed830c..3298261ae0e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue> propTemplateOutput = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTemplateOutput.TryReadProperty(ref reader, options, PropTemplateOutput, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + 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/_Generated/Api/Rollup/DeleteJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs index aa025a5e23b..80bcb007656 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs @@ -69,6 +69,11 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi { } + [JsonConstructor] + internal DeleteJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.RollupDeleteJob; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -76,6 +81,14 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override bool SupportsBody => false; internal override string OperationName => "rollup.delete_job"; + + /// + /// + /// Identifier for the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs index ecf093b6b08..4aecac74719 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class DeleteJobResponseConverter : 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 PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + + 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); + LocalJsonValue propAcknowledged = default; + LocalJsonValue?> propTaskFailures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propTaskFailures.TryReadProperty(ref reader, options, PropTaskFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TaskFailures = propTaskFailures.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, null, null); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteJobResponseConverter))] public sealed partial class DeleteJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs index fdf23d38c7e..c0617c416ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs @@ -47,6 +47,7 @@ public sealed partial class GetJobsRequestParameters : RequestParameters /// public sealed partial class GetJobsRequest : PlainRequest { + [JsonConstructor] public GetJobsRequest() { } @@ -62,6 +63,15 @@ public GetJobsRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Option internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_jobs"; + + /// + /// + /// Identifier for the rollup job. + /// If it is _all or omitted, the API returns all rollup jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs index 94884fe565a..dceff2a6a0f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class GetJobsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + 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); + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propJobs.TryReadProperty(ref reader, options, PropJobs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 + { + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropJobs, value.Jobs, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobsResponseConverter))] public sealed partial class GetJobsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs index 7da32db36d5..b6a49931884 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs @@ -59,6 +59,7 @@ public sealed partial class GetRollupCapsRequestParameters : RequestParameters /// public sealed partial class GetRollupCapsRequest : PlainRequest { + [JsonConstructor] public GetRollupCapsRequest() { } @@ -74,6 +75,15 @@ public GetRollupCapsRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r. internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_rollup_caps"; + + /// + /// + /// Index, indices or index-pattern to return rollup capabilities for. + /// _all may be used to fetch rollup capabilities from all jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs index f9e818a1e27..597c17ff66f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs @@ -59,6 +59,11 @@ public GetRollupIndexCapsRequest(Elastic.Clients.Elasticsearch.Ids index) : base { } + [JsonConstructor] + internal GetRollupIndexCapsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.RollupGetRollupIndexCaps; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -66,6 +71,15 @@ public GetRollupIndexCapsRequest(Elastic.Clients.Elasticsearch.Ids index) : base internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_rollup_index_caps"; + + /// + /// + /// Data stream or index to check for rollup capabilities. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs index 32ac6dc9b6b..88dcf2c2eaa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs @@ -57,6 +57,11 @@ public PutJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required { } + [JsonConstructor] + internal PutJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.RollupPutJob; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -65,6 +70,18 @@ public PutJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required internal override string OperationName => "rollup.put_job"; + /// + /// + /// Identifier for the rollup job. This can be any alphanumeric string and uniquely identifies the + /// data that is associated with the rollup job. The ID is persistent; it is stored with the rolled + /// up data. If you create a job, let it run for a while, then delete the job, the data that the job + /// rolled up is still be associated with this job ID. You cannot create a new job with the same ID + /// since that could lead to problems with mismatched job configurations. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// A cron string which defines the intervals when the rollup job should be executed. When the interval diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs index 4182c776136..3192f9c3b30 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class PutJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + 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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutJobResponseConverter))] public sealed partial class PutJobResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class PutJobResponse : 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/_Generated/Api/Rollup/RollupSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs index 983b3bbff95..a6fc6a5dbb6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs @@ -47,62 +47,61 @@ public sealed partial class RollupSearchRequestParameters : RequestParameters public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } } -internal sealed partial class RollupSearchRequestConverter : JsonConverter +internal sealed partial class RollupSearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override RollupSearchRequest 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 PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override RollupSearchRequest 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 RollupSearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, RollupSearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Size.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RollupSearchRequest { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + Aggregations = propAggregations.Value + , + Query = propQuery.Value + , + Size = propSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, RollupSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); writer.WriteEndObject(); } } @@ -121,7 +120,8 @@ public RollupSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base { } - public RollupSearchRequest() + [JsonConstructor] + internal RollupSearchRequest() { } @@ -133,12 +133,18 @@ public RollupSearchRequest() internal override string OperationName => "rollup.rollup_search"; + /// + /// + /// Enables searching rolled-up data using the standard Query DSL. + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// 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); } /// @@ -146,7 +152,6 @@ public RollupSearchRequest() /// 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); } /// @@ -154,7 +159,6 @@ public RollupSearchRequest() /// Specifies aggregations. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -162,7 +166,6 @@ public RollupSearchRequest() /// Specifies a DSL query. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -170,7 +173,6 @@ public RollupSearchRequest() /// Must be zero if set, as rollups work on pre-aggregated data. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs index 16d3e49bdad..49166ab2a5b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs @@ -22,22 +22,124 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class RollupSearchResponseConverter : 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 PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + 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 RollupSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue> propHits = default; + LocalJsonValue propShards = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propHits.TryReadProperty(ref reader, options, PropHits, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RollupSearchResponse + { + Aggregations = propAggregations.Value +, + Hits = propHits.Value +, + Shards = propShards.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RollupSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, null); + writer.WriteProperty(options, PropHits, value.Hits, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteEndObject(); + } +} + +internal sealed partial class RollupSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(RollupSearchResponse<>); + } + + 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(RollupSearchResponseConverter<>).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(RollupSearchResponseConverterFactory))] public sealed partial class RollupSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata Hits { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { 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/_Generated/Api/Rollup/StartJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs index d5cfcc92559..ca4b90937eb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs @@ -47,6 +47,11 @@ public StartJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir { } + [JsonConstructor] + internal StartJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.RollupStartJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -54,6 +59,14 @@ public StartJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir internal override bool SupportsBody => false; internal override string OperationName => "rollup.start_job"; + + /// + /// + /// Identifier for the rollup job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs index 1d6d05f4ff7..998e27c9948 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class StartJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override StartJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStarted.TryReadProperty(ref reader, options, PropStarted, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartJobResponse + { + Started = propStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStarted, value.Started, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartJobResponseConverter))] public sealed partial class StartJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("started")] public bool Started { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs index f4129512b7e..5a5e3df0d36 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs @@ -62,6 +62,11 @@ public StopJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Require { } + [JsonConstructor] + internal StopJobRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.RollupStopJob; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -70,6 +75,14 @@ public StopJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Require internal override string OperationName => "rollup.stop_job"; + /// + /// + /// Identifier for the rollup job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// If wait_for_completion is true, the API blocks for (at maximum) the specified duration while waiting for the job to stop. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs index 9f696d586bc..471885b6110 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class StopJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryReadProperty(ref reader, options, PropStopped, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopJobResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopJobResponseConverter))] public sealed partial class StopJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteRequest.g.cs index ddf8dbfa7ec..a6166f34870 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class ScriptsPainlessExecuteRequestParameters : RequestPar /// public sealed partial class ScriptsPainlessExecuteRequest : PlainRequest { + [JsonConstructor] + internal ScriptsPainlessExecuteRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceScriptsPainlessExecute; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs index d2c5569f64c..460c1912295 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs @@ -22,13 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ScriptsPainlessExecuteResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override ScriptsPainlessExecuteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryReadProperty(ref reader, options, PropResult, static TResult (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker))!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScriptsPainlessExecuteResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScriptsPainlessExecuteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TResult v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteEndObject(); + } +} + +internal sealed partial class ScriptsPainlessExecuteResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ScriptsPainlessExecuteResponse<>); + } + + 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(ScriptsPainlessExecuteResponseConverter<>).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(ScriptsPainlessExecuteResponseConverterFactory))] public sealed partial class ScriptsPainlessExecuteResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] - [SourceConverter] public TResult Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollRequest.g.cs index 71eeba5ada6..2ec64f901ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollRequest.g.cs @@ -64,6 +64,11 @@ public sealed partial class ScrollRequestParameters : RequestParameters /// public sealed partial class ScrollRequest : PlainRequest { + [JsonConstructor] + internal ScrollRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceScroll; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs index 056d1985d46..e221af59125 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs @@ -22,38 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHitsMetadata.TryReadProperty(ref reader, options, PropHitsMetadata, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs index 0821769f39a..f129da9f5d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs @@ -46,6 +46,11 @@ public DeleteBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) { } + [JsonConstructor] + internal DeleteBehavioralAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationDeleteBehavioralAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,14 @@ public DeleteBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) internal override bool SupportsBody => false; internal override string OperationName => "search_application.delete_behavioral_analytics"; + + /// + /// + /// The name of the analytics collection to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs index 815097e6f70..a9188898834 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class DeleteBehavioralAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteBehavioralAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteBehavioralAnalyticsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteBehavioralAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteBehavioralAnalyticsResponseConverter))] public sealed partial class DeleteBehavioralAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class DeleteBehavioralAnalyticsResponse : 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/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs index 3683272e428..5989871a25a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs @@ -46,6 +46,11 @@ public DeleteSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal DeleteSearchApplicationRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,14 @@ public DeleteSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "search_application.delete"; + + /// + /// + /// The name of the search application to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs index 25ab747e186..7fd03288fab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class DeleteSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSearchApplicationResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSearchApplicationResponseConverter))] public sealed partial class DeleteSearchApplicationResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class DeleteSearchApplicationResponse : 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/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs index 3032d656690..86ae32f2275 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs @@ -41,6 +41,7 @@ public sealed partial class GetBehavioralAnalyticsRequestParameters : RequestPar /// public sealed partial class GetBehavioralAnalyticsRequest : PlainRequest { + [JsonConstructor] public GetBehavioralAnalyticsRequest() { } @@ -56,6 +57,14 @@ public GetBehavioralAnalyticsRequest(IReadOnlyCollection false; internal override string OperationName => "search_application.get_behavioral_analytics"; + + /// + /// + /// A list of analytics collections to limit the returned information + /// + /// + [JsonIgnore] + public ICollection? Name { get => P?>("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs index e7342f567b8..786b405b35a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs @@ -45,6 +45,11 @@ public GetSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba { } + [JsonConstructor] + internal GetSearchApplicationRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -52,6 +57,14 @@ public GetSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override bool SupportsBody => false; internal override string OperationName => "search_application.get"; + + /// + /// + /// The name of the search application + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs index e8dfe37f8c5..17b6083e321 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class GetSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyticsCollectionName = System.Text.Json.JsonEncodedText.Encode("analytics_collection_name"); + 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"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + private static readonly System.Text.Json.JsonEncodedText PropUpdatedAtMillis = System.Text.Json.JsonEncodedText.Encode("updated_at_millis"); + + public override GetSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyticsCollectionName = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propName = default; + LocalJsonValue propTemplate = default; + LocalJsonValue propUpdatedAtMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyticsCollectionName.TryReadProperty(ref reader, options, PropAnalyticsCollectionName, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propTemplate.TryReadProperty(ref reader, options, PropTemplate, null)) + { + continue; + } + + if (propUpdatedAtMillis.TryReadProperty(ref reader, options, PropUpdatedAtMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSearchApplicationResponse + { + AnalyticsCollectionName = propAnalyticsCollectionName.Value +, + Indices = propIndices.Value +, + Name = propName.Value +, + Template = propTemplate.Value +, + UpdatedAtMillis = propUpdatedAtMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyticsCollectionName, value.AnalyticsCollectionName, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropTemplate, value.Template, null, null); + writer.WriteProperty(options, PropUpdatedAtMillis, value.UpdatedAtMillis, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSearchApplicationResponseConverter))] public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse { /// @@ -33,7 +114,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Analytics collection associated to the Search Application. /// /// - [JsonInclude, JsonPropertyName("analytics_collection_name")] public string? AnalyticsCollectionName { get; init; } /// @@ -41,7 +121,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Indices that are part of the Search Application. /// /// - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } /// @@ -49,7 +128,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Search Application name /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } /// @@ -57,7 +135,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Search template to use on search operations. /// /// - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationTemplate? Template { get; init; } /// @@ -65,6 +142,5 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Last time the Search Application was updated. /// /// - [JsonInclude, JsonPropertyName("updated_at_millis")] public long UpdatedAtMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListRequest.g.cs index 4a1abd18f85..ff6031dfe55 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListRequest.g.cs @@ -61,6 +61,11 @@ public sealed partial class ListRequestParameters : RequestParameters /// public sealed partial class ListRequest : PlainRequest { + [JsonConstructor] + internal ListRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationList; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs index c1945b4a695..1d39e38d4a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class ListResponseConverter : 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 ListResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propResults.TryReadProperty(ref reader, options, PropResults, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count, null, null); + writer.WriteProperty(options, PropResults, value.Results, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListResponseConverter))] public sealed partial class ListResponse : 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/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs index 9b13e1d8a6a..1284fe75103 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs @@ -45,6 +45,11 @@ public PutBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal PutBehavioralAnalyticsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationPutBehavioralAnalytics; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -52,6 +57,14 @@ public PutBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "search_application.put_behavioral_analytics"; + + /// + /// + /// The name of the analytics collection to be created or updated. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs index 9ef176986b8..73e6a1b242b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class PutBehavioralAnalyticsResponseConverter : 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 PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override PutBehavioralAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutBehavioralAnalyticsResponse + { + Acknowledged = propAcknowledged.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutBehavioralAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutBehavioralAnalyticsResponseConverter))] public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchResponse { /// @@ -33,7 +84,6 @@ public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchRespon /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } /// @@ -41,6 +91,5 @@ public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchRespon /// The name of the analytics collection created or updated /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs index 09736ffa1d9..a99576ae931 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs @@ -40,17 +40,36 @@ public sealed partial class PutSearchApplicationRequestParameters : RequestParam public bool? Create { get => Q("create"); set => Q("create", value); } } +internal sealed partial class PutSearchApplicationRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override PutSearchApplicationRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new PutSearchApplicationRequest { SearchApplication = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSearchApplicationRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.SearchApplication, null); + } +} + /// /// /// Create or update a search application. /// /// -public sealed partial class PutSearchApplicationRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(PutSearchApplicationRequestConverter))] +public sealed partial class PutSearchApplicationRequest : PlainRequest { public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) { } + [JsonConstructor] + internal PutSearchApplicationRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationPut; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -59,20 +78,20 @@ public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "search_application.put"; + /// + /// + /// The name of the search application to be created or updated. + /// + /// + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, this request cannot replace or update existing Search Applications. /// /// - [JsonIgnore] public bool? Create { get => Q("create"); set => Q("create", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationParameters SearchApplication { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, SearchApplication, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs index 142ce716eb0..44eaa0a8af1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class PutSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSearchApplicationResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSearchApplicationResponseConverter))] public sealed partial class PutSearchApplicationResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs index 173d6962b99..c9f4fd04554 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs @@ -53,6 +53,11 @@ public SearchApplicationSearchRequest(Elastic.Clients.Elasticsearch.Name name) : { } + [JsonConstructor] + internal SearchApplicationSearchRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationSearch; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -61,6 +66,14 @@ public SearchApplicationSearchRequest(Elastic.Clients.Elasticsearch.Name name) : internal override string OperationName => "search_application.search"; + /// + /// + /// The name of the search application to be searched. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Determines whether aggregation names are prefixed by their respective types in the response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs index 65205873d88..41b50eb3cf4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs @@ -22,38 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class SearchApplicationSearchResponseConverter : 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 SearchApplicationSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHitsMetadata.TryReadProperty(ref reader, options, PropHitsMetadata, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchApplicationSearchResponse + { + 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, SearchApplicationSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchApplicationSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchApplicationSearchResponse<>); + } + + 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(SearchApplicationSearchResponseConverter<>).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(SearchApplicationSearchResponseConverterFactory))] public sealed partial class SearchApplicationSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/SearchMvtRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs index 2863e257262..b7113374412 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs @@ -34,6 +34,174 @@ 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); + LocalJsonValue?> propAggs = default; + LocalJsonValue propBuffer = default; + LocalJsonValue propExactBounds = default; + LocalJsonValue propExtent = default; + LocalJsonValue propFields = default; + LocalJsonValue propGridAgg = default; + LocalJsonValue propGridPrecision = default; + LocalJsonValue propGridType = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propWithLabels = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggs.TryReadProperty(ref reader, options, PropAggs, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propBuffer.TryReadProperty(ref reader, options, PropBuffer, null)) + { + continue; + } + + if (propExactBounds.TryReadProperty(ref reader, options, PropExactBounds, null)) + { + continue; + } + + if (propExtent.TryReadProperty(ref reader, options, PropExtent, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propGridAgg.TryReadProperty(ref reader, options, PropGridAgg, null)) + { + continue; + } + + if (propGridPrecision.TryReadProperty(ref reader, options, PropGridPrecision, null)) + { + continue; + } + + if (propGridType.TryReadProperty(ref reader, options, PropGridType, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propTrackTotalHits.TryReadProperty(ref reader, options, PropTrackTotalHits, null)) + { + continue; + } + + if (propWithLabels.TryReadProperty(ref reader, options, PropWithLabels, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropBuffer, value.Buffer, null, null); + writer.WriteProperty(options, PropExactBounds, value.ExactBounds, null, null); + writer.WriteProperty(options, PropExtent, value.Extent, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropGridAgg, value.GridAgg, null, null); + writer.WriteProperty(options, PropGridPrecision, value.GridPrecision, null, null); + writer.WriteProperty(options, PropGridType, value.GridType, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits, null, null); + writer.WriteProperty(options, PropWithLabels, value.WithLabels, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Search a vector tile. @@ -42,12 +210,18 @@ 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.Indices indices, Elastic.Clients.Elasticsearch.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)) { } + [JsonConstructor] + internal SearchMvtRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceSearchMvt; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -56,6 +230,41 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C internal override string OperationName => "search_mvt"; + /// + /// + /// Field containing geospatial data to return + /// + /// + public Elastic.Clients.Elasticsearch.Field Field { get => P("field"); set => PR("field", value); } + + /// + /// + /// Comma-separated list of data streams, indices, or aliases to search + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// X coordinate for the vector tile to search + /// + /// + public int x { get => P("x"); set => PR("x", value); } + + /// + /// + /// Y coordinate for the vector tile to search + /// + /// + public int y { get => P("y"); set => PR("y", value); } + + /// + /// + /// Zoom level for the vector tile to search + /// + /// + public int Zoom { get => P("zoom"); set => PR("zoom", value); } + /// /// /// Sub-aggregations for the geotile_grid. @@ -91,7 +300,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// /// /// - [JsonInclude, JsonPropertyName("aggs")] public IDictionary? Aggs { get; set; } /// @@ -100,7 +308,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// to avoid outline artifacts from geometries that extend past the extent of the tile. /// /// - [JsonInclude, JsonPropertyName("buffer")] public int? Buffer { get; set; } /// @@ -112,7 +319,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// bounding box may be larger than the vector tile. /// /// - [JsonInclude, JsonPropertyName("exact_bounds")] public bool? ExactBounds { get; set; } /// @@ -120,7 +326,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// 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 +335,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// values may return inconsistent results. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -139,7 +342,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// Aggregation used to create a grid for the field. /// /// - [JsonInclude, JsonPropertyName("grid_agg")] public Elastic.Clients.Elasticsearch.Core.SearchMvt.GridAggregationType? GridAgg { get; set; } /// @@ -149,7 +351,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// don’t include the aggs layer. /// /// - [JsonInclude, JsonPropertyName("grid_precision")] public int? GridPrecision { get; set; } /// @@ -160,7 +361,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// of the cell. /// /// - [JsonInclude, JsonPropertyName("grid_type")] public Elastic.Clients.Elasticsearch.Core.SearchMvt.GridType? GridType { get; set; } /// @@ -168,7 +368,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// Query DSL used to filter documents for the search. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -177,7 +376,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -186,7 +384,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// If 0, results don’t include the hits layer. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -196,8 +393,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// from longest to shortest. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -207,7 +402,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -216,7 +410,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// suggested label positions for the original features. /// /// - [JsonInclude, JsonPropertyName("with_labels")] public bool? WithLabels { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs index 7c11901438f..0b415a00faa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs @@ -273,434 +273,371 @@ 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 PropRank = System.Text.Json.JsonEncodedText.Encode("rank"); + 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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue propRank = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue propRetriever = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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 == "rank") - { - variant.Rank = 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 (propCollapse.TryReadProperty(ref reader, options, PropCollapse, null)) + { + continue; + } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propDocvalueFields.TryReadProperty(ref reader, options, PropDocvalueFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExt.TryReadProperty(ref reader, options, PropExt, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propFields.TryReadProperty(ref reader, options, PropFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndicesBoost.TryReadProperty(ref reader, options, PropIndicesBoost, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, static IDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!))) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propKnn.TryReadProperty(ref reader, options, PropKnn, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propPit.TryReadProperty(ref reader, options, PropPit, null)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPostFilter.TryReadProperty(ref reader, options, PropPostFilter, null)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRank.TryReadProperty(ref reader, options, PropRank, null)) + { + continue; + } - if (value.Rank is not null) - { - writer.WritePropertyName("rank"); - JsonSerializer.Serialize(writer, value.Rank, options); - } + if (propRescore.TryReadProperty(ref reader, options, PropRescore, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRetriever.TryReadProperty(ref reader, options, PropRetriever, null)) + { + continue; + } - if (value.Retriever is not null) - { - writer.WritePropertyName("retriever"); - JsonSerializer.Serialize(writer, value.Retriever, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSeqNoPrimaryTerm.TryReadProperty(ref reader, options, PropSeqNoPrimaryTerm, null)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSlice.TryReadProperty(ref reader, options, PropSlice, null)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propStats.TryReadProperty(ref reader, options, PropStats, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propTerminateAfter.TryReadProperty(ref reader, options, PropTerminateAfter, null)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTimeout.TryReadProperty(ref reader, options, PropTimeout, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTrackScores.TryReadProperty(ref reader, options, PropTrackScores, null)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackTotalHits.TryReadProperty(ref reader, options, PropTrackTotalHits, null)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + 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 + , + Rank = propRank.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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropCollapse, value.Collapse, null, null); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropExt, value.Ext, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropKnn, value.Knn, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropPit, value.Pit, null, null); + writer.WriteProperty(options, PropPostFilter, value.PostFilter, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropRank, value.Rank, null, null); + writer.WriteProperty(options, PropRescore, value.Rescore, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRetriever, value.Retriever, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSlice, value.Slice, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStats, value.Stats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter, null, null); + writer.WriteProperty(options, PropTimeout, value.Timeout, null, null); + writer.WriteProperty(options, PropTrackScores, value.TrackScores, null, null); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); writer.WriteEndObject(); } } @@ -718,6 +655,7 @@ public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSeria [JsonConverter(typeof(SearchRequestConverter))] public partial class SearchRequest : PlainRequest { + [JsonConstructor] public SearchRequest() { } @@ -734,6 +672,15 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "search"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. @@ -741,7 +688,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -749,7 +695,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -758,7 +703,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -767,7 +711,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -776,7 +719,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -784,7 +726,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -793,7 +734,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -802,7 +742,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -812,7 +751,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Supports comma-separated values, such as open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -822,7 +760,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Fetches with this enabled will be slower the enabling synthetic source natively in the index. /// /// - [JsonIgnore] public bool? ForceSyntheticSource { get => Q("force_synthetic_source"); set => Q("force_synthetic_source", value); } /// @@ -830,7 +767,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -838,7 +774,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -847,7 +782,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -856,7 +790,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -871,7 +804,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// <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); } /// @@ -884,7 +816,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -893,7 +824,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -902,7 +832,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defaults to index level settings. /// /// - [JsonIgnore] public bool? RequestCache { get => Q("request_cache"); set => Q("request_cache", value); } /// @@ -910,7 +839,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -918,7 +846,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -928,7 +855,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// You can change this limit using the search.max_keep_alive cluster-level setting. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Scroll { get => Q("scroll"); set => Q("scroll", value); } /// @@ -936,7 +862,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// How distributed term frequencies are calculated for relevance scoring. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -946,7 +871,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -957,7 +881,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -965,7 +888,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -974,7 +896,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -983,7 +904,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -992,7 +912,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -1000,7 +919,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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); } /// @@ -1008,7 +926,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the aggregations that are run as part of the search request. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -1016,7 +933,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Collapses search results the values of the specified field. /// /// - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -1025,7 +941,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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; } /// @@ -1033,7 +948,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -1041,7 +955,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -1050,7 +963,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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; } /// @@ -1061,7 +973,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -1069,7 +980,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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.Core.Search.Highlight? Highlight { get; set; } /// @@ -1077,7 +987,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -1085,8 +994,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -1095,7 +1002,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Documents with a lower _score are not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -1104,7 +1010,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If you provide a PIT, you cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; set; } /// @@ -1114,7 +1019,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// A post filter has no impact on the aggregation results. /// /// - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; set; } /// @@ -1123,7 +1027,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// NOTE: This is a debugging tool and adds significant overhead to search execution. /// /// - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -1131,7 +1034,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -1139,7 +1041,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the Reciprocal Rank Fusion (RRF) to use. /// /// - [JsonInclude, JsonPropertyName("rank")] public Elastic.Clients.Elasticsearch.Rank? Rank { get; set; } /// @@ -1147,8 +1048,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1156,7 +1055,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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.Retriever? Retriever { get; set; } /// @@ -1165,7 +1063,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// These fields take precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1173,7 +1070,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Retrieve a script evaluation (based on different fields) for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -1181,7 +1077,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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; } /// @@ -1189,7 +1084,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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; } /// @@ -1199,7 +1093,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -1207,7 +1100,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Can be used to split a scrolled search into multiple slices that can be consumed independently. /// /// - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.SlicedScroll? Slice { get; set; } /// @@ -1215,8 +1107,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// A comma-separated list of <field>:<direction> pairs. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1225,7 +1115,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// These fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -1235,7 +1124,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// You can retrieve these stats using the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1246,8 +1134,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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.Fields? StoredFields { get; set; } /// @@ -1255,7 +1141,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines a suggester that provides similar looking terms based on a provided text. /// /// - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; set; } /// @@ -1270,7 +1155,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If set to 0 (default), the query does not terminate early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1280,7 +1164,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1288,7 +1171,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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; } /// @@ -1298,7 +1180,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If false, the response does not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1306,7 +1187,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// 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/_Generated/Api/SearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs index 2d2eba622c5..942a9e4751b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs @@ -22,38 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHitsMetadata.TryReadProperty(ref reader, options, PropHitsMetadata, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/SearchShardsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs index 9e3baa8588e..17dbc580ad9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs @@ -93,6 +93,7 @@ public sealed partial class SearchShardsRequestParameters : RequestParameters /// public sealed partial class SearchShardsRequest : PlainRequest { + [JsonConstructor] public SearchShardsRequest() { } @@ -109,6 +110,14 @@ public SearchShardsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : bas internal override string OperationName => "search_shards"; + /// + /// + /// Returns the indices and shards that a search request would be executed against. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs index 2914a6a88f7..e7f87a637e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs @@ -22,17 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class SearchShardsResponseConverter : 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 PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("shards"); + + public override SearchShardsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + LocalJsonValue> propNodes = default; + LocalJsonValue>> propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchShardsResponse + { + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchShardsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropShards, value.Shards, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchShardsResponseConverter))] public sealed partial class SearchShardsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Core.SearchShards.ShardStoreIndex))] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("shards")] public IReadOnlyCollection> Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs index 79f27aa0434..8435be38066 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs @@ -124,6 +124,7 @@ public sealed partial class SearchTemplateRequestParameters : RequestParameters /// public sealed partial class SearchTemplateRequest : PlainRequest { + [JsonConstructor] public SearchTemplateRequest() { } @@ -140,6 +141,15 @@ public SearchTemplateRequest(Elastic.Clients.Elasticsearch.Indices? indices) : b internal override string OperationName => "search_template"; + /// + /// + /// Comma-separated list of data streams, indices, + /// and aliases to search. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs index 051c600694e..dfd1fac26b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs @@ -22,38 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHits = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHits.TryReadProperty(ref reader, options, PropHits, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHits, value.Hits, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + 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.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs index e7abfbbbe1c..98be69c4ff7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs @@ -43,6 +43,7 @@ public sealed partial class CacheStatsRequestParameters : RequestParameters /// public sealed partial class CacheStatsRequest : PlainRequest { + [JsonConstructor] public CacheStatsRequest() { } @@ -59,6 +60,13 @@ public CacheStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base(r internal override string OperationName => "searchable_snapshots.cache_stats"; + /// + /// + /// A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you're connecting to, leave empty to get information from all nodes + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs index 6b810e01d41..a69ca18bf55 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class CacheStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override CacheStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CacheStatsResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CacheStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CacheStatsResponseConverter))] public sealed partial class CacheStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs index 92a8547f9d3..4951f85ddf7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs @@ -62,6 +62,7 @@ public sealed partial class ClearCacheRequestParameters : RequestParameters /// public sealed partial class ClearCacheRequest : PlainRequest { + [JsonConstructor] public ClearCacheRequest() { } @@ -78,6 +79,14 @@ public ClearCacheRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "searchable_snapshots.clear_cache"; + /// + /// + /// A comma-separated list of index names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs index fd393b4da9f..14fb3f64cdb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs @@ -68,6 +68,11 @@ public MountRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Clien { } + [JsonConstructor] + internal MountRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SearchableSnapshotsMount; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -76,6 +81,22 @@ public MountRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Clien internal override string OperationName => "searchable_snapshots.mount"; + /// + /// + /// The name of the repository containing the snapshot of the index to mount + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// The name of the snapshot of the index to mount + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs index 9ae28a8c3cf..17fe40cec69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class MountResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override MountResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshot.TryReadProperty(ref reader, options, PropSnapshot, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MountResponse + { + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MountResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshot, value.Snapshot, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MountResponseConverter))] public sealed partial class MountResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.SearchableSnapshots.MountedSnapshot Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs index 24db2126902..025f642cb9c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs @@ -47,6 +47,7 @@ public sealed partial class SearchableSnapshotsStatsRequestParameters : RequestP /// public sealed partial class SearchableSnapshotsStatsRequest : PlainRequest { + [JsonConstructor] public SearchableSnapshotsStatsRequest() { } @@ -63,6 +64,14 @@ public SearchableSnapshotsStatsRequest(Elastic.Clients.Elasticsearch.Indices? in internal override string OperationName => "searchable_snapshots.stats"; + /// + /// + /// A comma-separated list of index names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Return stats aggregated at cluster, index or shard level diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs index fc66cfe509e..630f7ddef14 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class SearchableSnapshotsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override SearchableSnapshotsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStats = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStats.TryReadProperty(ref reader, options, PropStats, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchableSnapshotsStatsResponse + { + Stats = propStats.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchableSnapshotsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStats, value.Stats, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchableSnapshotsStatsResponseConverter))] public sealed partial class SearchableSnapshotsStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stats")] public object Stats { get; init; } - [JsonInclude, JsonPropertyName("total")] public object Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileRequest.g.cs index 6efb0a6afae..5dc4f2d840c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class ActivateUserProfileRequestParameters : RequestParame /// public sealed partial class ActivateUserProfileRequest : PlainRequest { + [JsonConstructor] + internal ActivateUserProfileRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityActivateUserProfile; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs index e3935e35022..8917becb96c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs @@ -22,24 +22,118 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propData = default; + LocalJsonValue propDoc = default; + LocalJsonValue propEnabled = default; + LocalJsonValue> propLabels = default; + LocalJsonValue propLastSynchronized = default; + LocalJsonValue propUid = default; + LocalJsonValue propUser = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryReadProperty(ref reader, options, PropData, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propDoc.TryReadProperty(ref reader, options, PropDoc, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propLabels.TryReadProperty(ref reader, options, PropLabels, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propLastSynchronized.TryReadProperty(ref reader, options, PropLastSynchronized, null)) + { + continue; + } + + if (propUid.TryReadProperty(ref reader, options, PropUid, null)) + { + continue; + } + + if (propUser.TryReadProperty(ref reader, options, PropUser, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropDoc, value.Doc, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropLabels, value.Labels, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropLastSynchronized, value.LastSynchronized, null, null); + writer.WriteProperty(options, PropUid, value.Uid, null, null); + writer.WriteProperty(options, PropUser, value.User, null, null); + 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.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.Security.UserProfileUser User { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateRequest.g.cs index e070e72ef85..e7ec7b4546e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateRequest.g.cs @@ -47,6 +47,11 @@ public sealed partial class AuthenticateRequestParameters : RequestParameters /// public sealed partial class AuthenticateRequest : PlainRequest { + [JsonConstructor] + internal AuthenticateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityAuthenticate; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs index 0ce01ead1df..3fd97091167 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs @@ -22,32 +22,162 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propApiKey = default; + LocalJsonValue propAuthenticationRealm = default; + LocalJsonValue propAuthenticationType = default; + LocalJsonValue propEmail = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFullName = default; + LocalJsonValue propLookupRealm = default; + LocalJsonValue> propMetadata = default; + LocalJsonValue> propRoles = default; + LocalJsonValue propToken = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryReadProperty(ref reader, options, PropApiKey, null)) + { + continue; + } + + if (propAuthenticationRealm.TryReadProperty(ref reader, options, PropAuthenticationRealm, null)) + { + continue; + } + + if (propAuthenticationType.TryReadProperty(ref reader, options, PropAuthenticationType, null)) + { + continue; + } + + if (propEmail.TryReadProperty(ref reader, options, PropEmail, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propFullName.TryReadProperty(ref reader, options, PropFullName, null)) + { + continue; + } + + if (propLookupRealm.TryReadProperty(ref reader, options, PropLookupRealm, null)) + { + continue; + } + + if (propMetadata.TryReadProperty(ref reader, options, PropMetadata, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propRoles.TryReadProperty(ref reader, options, PropRoles, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propToken.TryReadProperty(ref reader, options, PropToken, null)) + { + continue; + } + + if (propUsername.TryReadProperty(ref reader, options, PropUsername, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAuthenticationRealm, value.AuthenticationRealm, null, null); + writer.WriteProperty(options, PropAuthenticationType, value.AuthenticationType, null, null); + writer.WriteProperty(options, PropEmail, value.Email, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropFullName, value.FullName, null, null); + writer.WriteProperty(options, PropLookupRealm, value.LookupRealm, null, null); + writer.WriteProperty(options, PropMetadata, value.Metadata, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropRoles, value.Roles, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropToken, value.Token, null, null); + writer.WriteProperty(options, PropUsername, value.Username, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AuthenticateResponseConverter))] public sealed partial class AuthenticateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_key")] public Elastic.Clients.Elasticsearch.Security.AuthenticateApiKey? ApiKey { get; init; } - [JsonInclude, JsonPropertyName("authentication_realm")] public Elastic.Clients.Elasticsearch.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.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.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/_Generated/Api/Security/BulkDeleteRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleRequest.g.cs index c078ddfd772..d650b594a94 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleRequest.g.cs @@ -51,6 +51,11 @@ public sealed partial class BulkDeleteRoleRequestParameters : RequestParameters /// public sealed partial class BulkDeleteRoleRequest : PlainRequest { + [JsonConstructor] + internal BulkDeleteRoleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityBulkDeleteRole; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs index c09c14e8c35..a109545660f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propDeleted = default; + LocalJsonValue propErrors = default; + LocalJsonValue?> propNotFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryReadProperty(ref reader, options, PropDeleted, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propErrors.TryReadProperty(ref reader, options, PropErrors, null)) + { + continue; + } + + if (propNotFound.TryReadProperty(ref reader, options, PropNotFound, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropErrors, value.Errors, null, null); + writer.WriteProperty(options, PropNotFound, value.NotFound, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkDeleteRoleResponseConverter))] public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse { /// @@ -33,7 +94,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Array of deleted roles /// /// - [JsonInclude, JsonPropertyName("deleted")] public IReadOnlyCollection? Deleted { get; init; } /// @@ -41,7 +101,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Present if any deletes resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.BulkError? Errors { get; init; } /// @@ -49,6 +108,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/_Generated/Api/Security/BulkPutRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleRequest.g.cs index 15cd7c44396..b9c663afed5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleRequest.g.cs @@ -51,6 +51,11 @@ public sealed partial class BulkPutRoleRequestParameters : RequestParameters /// public sealed partial class BulkPutRoleRequest : PlainRequest { + [JsonConstructor] + internal BulkPutRoleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityBulkPutRole; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs index 82e4e4312b5..aba0ccd703e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs @@ -22,10 +22,81 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propCreated = default; + LocalJsonValue propErrors = default; + LocalJsonValue?> propNoop = default; + LocalJsonValue?> propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryReadProperty(ref reader, options, PropCreated, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propErrors.TryReadProperty(ref reader, options, PropErrors, null)) + { + continue; + } + + if (propNoop.TryReadProperty(ref reader, options, PropNoop, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropErrors, value.Errors, null, null); + writer.WriteProperty(options, PropNoop, value.Noop, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropUpdated, value.Updated, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkPutRoleResponseConverter))] public sealed partial class BulkPutRoleResponse : ElasticsearchResponse { /// @@ -33,7 +104,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of created roles /// /// - [JsonInclude, JsonPropertyName("created")] public IReadOnlyCollection? Created { get; init; } /// @@ -41,7 +111,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Present if any updates resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.BulkError? Errors { get; init; } /// @@ -49,7 +118,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of role names without any changes /// /// - [JsonInclude, JsonPropertyName("noop")] public IReadOnlyCollection? Noop { get; init; } /// @@ -57,6 +125,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/_Generated/Api/Security/ChangePasswordRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs index 4c483138389..64943c535ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs @@ -50,6 +50,7 @@ public sealed partial class ChangePasswordRequestParameters : RequestParameters /// public sealed partial class ChangePasswordRequest : PlainRequest { + [JsonConstructor] public ChangePasswordRequest() { } @@ -66,6 +67,15 @@ public ChangePasswordRequest(Elastic.Clients.Elasticsearch.Username? username) : internal override string OperationName => "security.change_password"; + /// + /// + /// The user whose password you want to change. If you do not specify this + /// parameter, the password is changed for the current user. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username? Username { get => P("username"); set => PO("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs index 00c66d00ff6..b0beacb3431 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs @@ -22,10 +22,39 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ChangePasswordResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override ChangePasswordResponse 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) + { + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChangePasswordResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChangePasswordResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ChangePasswordResponseConverter))] public sealed partial class ChangePasswordResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs index 48b0f598878..9ee17104de7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs @@ -49,6 +49,11 @@ public ClearApiKeyCacheRequest(Elastic.Clients.Elasticsearch.Ids ids) : base(r = { } + [JsonConstructor] + internal ClearApiKeyCacheRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityClearApiKeyCache; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -56,6 +61,16 @@ public ClearApiKeyCacheRequest(Elastic.Clients.Elasticsearch.Ids ids) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "security.clear_api_key_cache"; + + /// + /// + /// Comma-separated list of API key IDs to evict from the API key cache. + /// To evict all API keys, use *. + /// Does not support other wildcard patterns. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Ids { get => P("ids"); set => PR("ids", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs index 65cdf04e9b0..57070ef5662 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs index 19bedb531d5..5077fe72ea5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs @@ -49,6 +49,11 @@ public ClearCachedPrivilegesRequest(Elastic.Clients.Elasticsearch.Name applicati { } + [JsonConstructor] + internal ClearCachedPrivilegesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityClearCachedPrivileges; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -56,6 +61,14 @@ public ClearCachedPrivilegesRequest(Elastic.Clients.Elasticsearch.Name applicati internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_privileges"; + + /// + /// + /// A comma-separated list of application names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Application { get => P("application"); set => PR("application", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs index d912eaa3cfd..3602f420149 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs index 0687c5d5d41..e88afaeefb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs @@ -54,6 +54,11 @@ public ClearCachedRealmsRequest(Elastic.Clients.Elasticsearch.Names realms) : ba { } + [JsonConstructor] + internal ClearCachedRealmsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityClearCachedRealms; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -62,6 +67,14 @@ public ClearCachedRealmsRequest(Elastic.Clients.Elasticsearch.Names realms) : ba internal override string OperationName => "security.clear_cached_realms"; + /// + /// + /// Comma-separated list of realms to clear + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Realms { get => P("realms"); set => PR("realms", value); } + /// /// /// Comma-separated list of usernames to clear from the cache diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs index 7f2e195891e..2ca9bd004a9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs index 1b630f2adff..a7ef576caa8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs @@ -48,6 +48,11 @@ public ClearCachedRolesRequest(Elastic.Clients.Elasticsearch.Names name) : base( { } + [JsonConstructor] + internal ClearCachedRolesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityClearCachedRoles; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -55,6 +60,14 @@ public ClearCachedRolesRequest(Elastic.Clients.Elasticsearch.Names name) : base( internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_roles"; + + /// + /// + /// Role name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs index 5257f5d7b69..5328ee4ddaa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs index a018b729fd4..7f753bc6c8a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs @@ -48,6 +48,11 @@ public ClearCachedServiceTokensRequest(string ns, string service, Elastic.Client { } + [JsonConstructor] + internal ClearCachedServiceTokensRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityClearCachedServiceTokens; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -55,6 +60,30 @@ public ClearCachedServiceTokensRequest(string ns, string service, Elastic.Client internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_service_tokens"; + + /// + /// + /// A comma-separated list of service token names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs index b1b33e09cf9..1119b0cd117 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null)) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propNodeStats.TryReadProperty(ref reader, options, PropNodeStats, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNodeStats, value.NodeStats, null, null); + 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.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyRequest.g.cs index cc79ddf4274..f20481b6df7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyRequest.g.cs @@ -53,6 +53,11 @@ public sealed partial class CreateApiKeyRequestParameters : RequestParameters /// public sealed partial class CreateApiKeyRequest : PlainRequest { + [JsonConstructor] + internal CreateApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityCreateApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs index 440179df1b5..babedf9ac1b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryReadProperty(ref reader, options, PropApiKey, null)) + { + continue; + } + + if (propEncoded.TryReadProperty(ref reader, options, PropEncoded, null)) + { + continue; + } + + if (propExpiration.TryReadProperty(ref reader, options, PropExpiration, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropEncoded, value.Encoded, null, null); + writer.WriteProperty(options, PropExpiration, value.Expiration, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateApiKeyResponseConverter))] public sealed partial class CreateApiKeyResponse : ElasticsearchResponse { /// @@ -33,7 +114,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Generated API key. /// /// - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } /// @@ -43,7 +123,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// by a colon (:). /// /// - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } /// @@ -51,7 +130,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Expiration in milliseconds for the API key. /// /// - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } /// @@ -59,7 +137,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Unique ID for this API key. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -67,6 +144,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/_Generated/Api/Security/CreateCrossClusterApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyRequest.g.cs index 2ca3d9d6e10..2ed9312c0ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyRequest.g.cs @@ -64,6 +64,11 @@ public sealed partial class CreateCrossClusterApiKeyRequestParameters : RequestP /// public sealed partial class CreateCrossClusterApiKeyRequest : PlainRequest { + [JsonConstructor] + internal CreateCrossClusterApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityCreateCrossClusterApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs index 3dcac6531a1..7d444b53fa2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class CreateCrossClusterApiKeyResponseConverter : 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 CreateCrossClusterApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryReadProperty(ref reader, options, PropApiKey, null)) + { + continue; + } + + if (propEncoded.TryReadProperty(ref reader, options, PropEncoded, null)) + { + continue; + } + + if (propExpiration.TryReadProperty(ref reader, options, PropExpiration, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateCrossClusterApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateCrossClusterApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey, null, null); + writer.WriteProperty(options, PropEncoded, value.Encoded, null, null); + writer.WriteProperty(options, PropExpiration, value.Expiration, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateCrossClusterApiKeyResponseConverter))] public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResponse { /// @@ -33,7 +114,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Generated API key. /// /// - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } /// @@ -43,7 +123,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// by a colon (:). /// /// - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } /// @@ -51,7 +130,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Expiration in milliseconds for the API key. /// /// - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } /// @@ -59,7 +137,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Unique ID for this API key. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -67,6 +144,5 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// 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/_Generated/Api/Security/CreateServiceTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs index 6b8dd3f4062..c31bd27d600 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs @@ -58,6 +58,11 @@ public CreateServiceTokenRequest(string ns, string service) : base(r => r.Requir { } + [JsonConstructor] + internal CreateServiceTokenRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityCreateServiceToken; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -66,6 +71,30 @@ public CreateServiceTokenRequest(string ns, string service) : base(r => r.Requir internal override string OperationName => "security.create_service_token"; + /// + /// + /// An identifier for the token name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } + /// /// /// If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs index 925204e9e00..e75eb268615 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCreated = default; + LocalJsonValue propToken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryReadProperty(ref reader, options, PropCreated, null)) + { + continue; + } + + if (propToken.TryReadProperty(ref reader, options, PropToken, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropToken, value.Token, null, null); + 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.Security.ServiceToken Token { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs index 320489f1431..8c60df41f6c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs @@ -51,6 +51,11 @@ public DeletePrivilegesRequest(Elastic.Clients.Elasticsearch.Name application, E { } + [JsonConstructor] + internal DeletePrivilegesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDeletePrivileges; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -59,6 +64,22 @@ public DeletePrivilegesRequest(Elastic.Clients.Elasticsearch.Name application, E internal override string OperationName => "security.delete_privileges"; + /// + /// + /// Application name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Application { get => P("application"); set => PR("application", value); } + + /// + /// + /// Privilege name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs index 2421e540477..3e9c707a1f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs @@ -51,6 +51,11 @@ public DeleteRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base( { } + [JsonConstructor] + internal DeleteRoleMappingRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDeleteRoleMapping; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -59,6 +64,14 @@ public DeleteRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base( internal override string OperationName => "security.delete_role_mapping"; + /// + /// + /// Role-mapping name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs index ba9829eeecf..bc271736f66 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Security/DeleteRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs index fd976f508f4..b110569b836 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs @@ -54,6 +54,11 @@ public DeleteRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r. { } + [JsonConstructor] + internal DeleteRoleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDeleteRole; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -62,6 +67,14 @@ public DeleteRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r. internal override string OperationName => "security.delete_role"; + /// + /// + /// Role name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs index 8733410e218..9205c7a0199 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs index 94441f708bb..1d1cc3b6b41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs @@ -54,6 +54,11 @@ public DeleteServiceTokenRequest(string ns, string service, Elastic.Clients.Elas { } + [JsonConstructor] + internal DeleteServiceTokenRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDeleteServiceToken; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -62,6 +67,30 @@ public DeleteServiceTokenRequest(string ns, string service, Elastic.Clients.Elas internal override string OperationName => "security.delete_service_token"; + /// + /// + /// An identifier for the token name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } + /// /// /// If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs index a9ad6329929..3cc80e41bc2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Security/DeleteUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs index 90e38b47654..89800f1d40e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs @@ -54,6 +54,11 @@ public DeleteUserRequest(Elastic.Clients.Elasticsearch.Username username) : base { } + [JsonConstructor] + internal DeleteUserRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDeleteUser; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -62,6 +67,14 @@ public DeleteUserRequest(Elastic.Clients.Elasticsearch.Username username) : base internal override string OperationName => "security.delete_user"; + /// + /// + /// username + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs index 3ccd3bafba1..ae0e30e2c32 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DeleteUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteUserResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteUserResponseConverter))] public sealed partial class DeleteUserResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs index ee4991e79cf..507c7e6d77e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs @@ -56,6 +56,11 @@ public DisableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) { } + [JsonConstructor] + internal DisableUserProfileRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDisableUserProfile; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -64,6 +69,14 @@ public DisableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) internal override string OperationName => "security.disable_user_profile"; + /// + /// + /// Unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// If 'true', Elasticsearch refreshes the affected shards to make this operation diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs index b6a983cec33..73d2c0873e5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DisableUserProfileResponseConverter))] public sealed partial class DisableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Security/DisableUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs index e8f286a5a80..1662c64716f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs @@ -54,6 +54,11 @@ public DisableUserRequest(Elastic.Clients.Elasticsearch.Username username) : bas { } + [JsonConstructor] + internal DisableUserRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityDisableUser; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -62,6 +67,14 @@ public DisableUserRequest(Elastic.Clients.Elasticsearch.Username username) : bas internal override string OperationName => "security.disable_user"; + /// + /// + /// The username of the user to disable + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs index 91cd0736f94..0328c9c5129 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs @@ -22,10 +22,39 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DisableUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override DisableUserResponse 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) + { + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DisableUserResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DisableUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DisableUserResponseConverter))] public sealed partial class DisableUserResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs index 725a5665805..e3941136c38 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs @@ -56,6 +56,11 @@ public EnableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) { } + [JsonConstructor] + internal EnableUserProfileRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityEnableUserProfile; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -64,6 +69,14 @@ public EnableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) internal override string OperationName => "security.enable_user_profile"; + /// + /// + /// Unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// If 'true', Elasticsearch refreshes the affected shards to make this operation diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs index 01d90498655..9cd4115782a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnableUserProfileResponseConverter))] public sealed partial class EnableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Security/EnableUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs index 4758880e9f4..d9b9fcceb64 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs @@ -54,6 +54,11 @@ public EnableUserRequest(Elastic.Clients.Elasticsearch.Username username) : base { } + [JsonConstructor] + internal EnableUserRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityEnableUser; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -62,6 +67,14 @@ public EnableUserRequest(Elastic.Clients.Elasticsearch.Username username) : base internal override string OperationName => "security.enable_user"; + /// + /// + /// The username of the user to enable + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs index e839c5abf6f..7235c2b2be6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs @@ -22,10 +22,39 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnableUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override EnableUserResponse 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) + { + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnableUserResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnableUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnableUserResponseConverter))] public sealed partial class EnableUserResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaRequest.g.cs index 51c0a32e140..ef809a2caa8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class EnrollKibanaRequestParameters : RequestParameters /// public sealed partial class EnrollKibanaRequest : PlainRequest { + [JsonConstructor] + internal EnrollKibanaRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityEnrollKibana; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs index 79907207140..b4d2937f7a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnrollKibanaResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHttpCa = System.Text.Json.JsonEncodedText.Encode("http_ca"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + + public override EnrollKibanaResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propHttpCa = default; + LocalJsonValue propToken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHttpCa.TryReadProperty(ref reader, options, PropHttpCa, null)) + { + continue; + } + + if (propToken.TryReadProperty(ref reader, options, PropToken, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrollKibanaResponse + { + HttpCa = propHttpCa.Value +, + Token = propToken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrollKibanaResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHttpCa, value.HttpCa, null, null); + writer.WriteProperty(options, PropToken, value.Token, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrollKibanaResponseConverter))] public sealed partial class EnrollKibanaResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("http_ca")] public string HttpCa { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Security.KibanaToken Token { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeRequest.g.cs index 580b4bc0b0c..42fb3da1809 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class EnrollNodeRequestParameters : RequestParameters /// public sealed partial class EnrollNodeRequest : PlainRequest { + [JsonConstructor] + internal EnrollNodeRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityEnrollNode; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs index 5d34b09a546..7e3b378a9b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs @@ -22,22 +22,107 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnrollNodeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHttpCaCert = System.Text.Json.JsonEncodedText.Encode("http_ca_cert"); + private static readonly System.Text.Json.JsonEncodedText PropHttpCaKey = System.Text.Json.JsonEncodedText.Encode("http_ca_key"); + private static readonly System.Text.Json.JsonEncodedText PropNodesAddresses = System.Text.Json.JsonEncodedText.Encode("nodes_addresses"); + private static readonly System.Text.Json.JsonEncodedText PropTransportCaCert = System.Text.Json.JsonEncodedText.Encode("transport_ca_cert"); + private static readonly System.Text.Json.JsonEncodedText PropTransportCert = System.Text.Json.JsonEncodedText.Encode("transport_cert"); + private static readonly System.Text.Json.JsonEncodedText PropTransportKey = System.Text.Json.JsonEncodedText.Encode("transport_key"); + + public override EnrollNodeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propHttpCaCert = default; + LocalJsonValue propHttpCaKey = default; + LocalJsonValue> propNodesAddresses = default; + LocalJsonValue propTransportCaCert = default; + LocalJsonValue propTransportCert = default; + LocalJsonValue propTransportKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHttpCaCert.TryReadProperty(ref reader, options, PropHttpCaCert, null)) + { + continue; + } + + if (propHttpCaKey.TryReadProperty(ref reader, options, PropHttpCaKey, null)) + { + continue; + } + + if (propNodesAddresses.TryReadProperty(ref reader, options, PropNodesAddresses, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTransportCaCert.TryReadProperty(ref reader, options, PropTransportCaCert, null)) + { + continue; + } + + if (propTransportCert.TryReadProperty(ref reader, options, PropTransportCert, null)) + { + continue; + } + + if (propTransportKey.TryReadProperty(ref reader, options, PropTransportKey, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrollNodeResponse + { + HttpCaCert = propHttpCaCert.Value +, + HttpCaKey = propHttpCaKey.Value +, + NodesAddresses = propNodesAddresses.Value +, + TransportCaCert = propTransportCaCert.Value +, + TransportCert = propTransportCert.Value +, + TransportKey = propTransportKey.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrollNodeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHttpCaCert, value.HttpCaCert, null, null); + writer.WriteProperty(options, PropHttpCaKey, value.HttpCaKey, null, null); + writer.WriteProperty(options, PropNodesAddresses, value.NodesAddresses, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTransportCaCert, value.TransportCaCert, null, null); + writer.WriteProperty(options, PropTransportCert, value.TransportCert, null, null); + writer.WriteProperty(options, PropTransportKey, value.TransportKey, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrollNodeResponseConverter))] public sealed partial class EnrollNodeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("http_ca_cert")] public string HttpCaCert { get; init; } - [JsonInclude, JsonPropertyName("http_ca_key")] public string HttpCaKey { get; init; } - [JsonInclude, JsonPropertyName("nodes_addresses")] public IReadOnlyCollection NodesAddresses { get; init; } - [JsonInclude, JsonPropertyName("transport_ca_cert")] public string TransportCaCert { get; init; } - [JsonInclude, JsonPropertyName("transport_cert")] public string TransportCert { get; init; } - [JsonInclude, JsonPropertyName("transport_key")] public string TransportKey { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyRequest.g.cs index 57ce8199ac0..0f98a3a4f33 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyRequest.g.cs @@ -110,6 +110,11 @@ public sealed partial class GetApiKeyRequestParameters : RequestParameters /// public sealed partial class GetApiKeyRequest : PlainRequest { + [JsonConstructor] + internal GetApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs index 39e7a09e307..9c0b2318d2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKeys.TryReadProperty(ref reader, options, PropApiKeys, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Security/GetBuiltinPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesRequest.g.cs index 218da5b567b..51c58cbd7a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class GetBuiltinPrivilegesRequestParameters : RequestParam /// public sealed partial class GetBuiltinPrivilegesRequest : PlainRequest { + [JsonConstructor] + internal GetBuiltinPrivilegesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetBuiltinPrivileges; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs index 2410a2d7776..3baa477c20f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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"); + private static readonly System.Text.Json.JsonEncodedText PropRemoteCluster = System.Text.Json.JsonEncodedText.Encode("remote_cluster"); + + 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); + LocalJsonValue> propCluster = default; + LocalJsonValue> propIndex = default; + LocalJsonValue> propRemoteCluster = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCluster.TryReadProperty(ref reader, options, PropCluster, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propRemoteCluster.TryReadProperty(ref reader, options, PropRemoteCluster, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + RemoteCluster = propRemoteCluster.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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndex, value.Index, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRemoteCluster, value.RemoteCluster, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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; } - [JsonInclude, JsonPropertyName("remote_cluster")] public IReadOnlyCollection RemoteCluster { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs index 54604deb0ad..313f0d9aa11 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs @@ -41,6 +41,7 @@ public sealed partial class GetPrivilegesRequestParameters : RequestParameters /// public sealed partial class GetPrivilegesRequest : PlainRequest { + [JsonConstructor] public GetPrivilegesRequest() { } @@ -60,6 +61,22 @@ public GetPrivilegesRequest(Elastic.Clients.Elasticsearch.Name? application, Ela internal override bool SupportsBody => false; internal override string OperationName => "security.get_privileges"; + + /// + /// + /// Application name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Application { get => P("application"); set => PO("application", value); } + + /// + /// + /// Privilege name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs index 8a4c6a97c43..d53db57694e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs @@ -46,6 +46,7 @@ public sealed partial class GetRoleMappingRequestParameters : RequestParameters /// public sealed partial class GetRoleMappingRequest : PlainRequest { + [JsonConstructor] public GetRoleMappingRequest() { } @@ -61,6 +62,14 @@ public GetRoleMappingRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r internal override bool SupportsBody => false; internal override string OperationName => "security.get_role_mapping"; + + /// + /// + /// The distinct name that identifies the role mapping. The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way. You can specify multiple mapping names as a comma-separated list. If you do not specify this parameter, the API returns information about all role mappings. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs index 9269177ee80..3ef742f54a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs @@ -44,6 +44,7 @@ public sealed partial class GetRoleRequestParameters : RequestParameters /// public sealed partial class GetRoleRequest : PlainRequest { + [JsonConstructor] public GetRoleRequest() { } @@ -59,6 +60,14 @@ public GetRoleRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.O internal override bool SupportsBody => false; internal override string OperationName => "security.get_role"; + + /// + /// + /// The name of the role. You can specify multiple roles as a comma-separated list. If you do not specify this parameter, the API returns information about all roles. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs index 921b203f237..20d588ea6d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs @@ -44,6 +44,7 @@ public sealed partial class GetServiceAccountsRequestParameters : RequestParamet /// public sealed partial class GetServiceAccountsRequest : PlainRequest { + [JsonConstructor] public GetServiceAccountsRequest() { } @@ -63,6 +64,22 @@ public GetServiceAccountsRequest(string? ns) : base(r => r.Optional("namespace", internal override bool SupportsBody => false; internal override string OperationName => "security.get_service_accounts"; + + /// + /// + /// Name of the namespace. Omit this parameter to retrieve information about all service accounts. If you omit this parameter, you must also omit the service parameter. + /// + /// + [JsonIgnore] + public string? Namespace { get => P("namespace"); set => PO("namespace", value); } + + /// + /// + /// Name of the service name. Omit this parameter to retrieve information about all service accounts that belong to the specified namespace. + /// + /// + [JsonIgnore] + public string? Service { get => P("service"); set => PO("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs index a1a5d627f24..15e185cf93c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs @@ -45,6 +45,11 @@ public GetServiceCredentialsRequest(string ns, Elastic.Clients.Elasticsearch.Nam { } + [JsonConstructor] + internal GetServiceCredentialsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetServiceCredentials; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -52,6 +57,22 @@ public GetServiceCredentialsRequest(string ns, Elastic.Clients.Elasticsearch.Nam internal override bool SupportsBody => false; internal override string OperationName => "security.get_service_credentials"; + + /// + /// + /// Name of the namespace. + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// Name of the service name. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Service { get => P("service"); set => PR("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs index 7fa558776e9..bc1396e9e15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs @@ -22,13 +22,83 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue propNodesCredentials = default; + LocalJsonValue propServiceAccount = default; + LocalJsonValue>> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propNodesCredentials.TryReadProperty(ref reader, options, PropNodesCredentials, null)) + { + continue; + } + + if (propServiceAccount.TryReadProperty(ref reader, options, PropServiceAccount, null)) + { + continue; + } + + if (propTokens.TryReadProperty(ref reader, options, PropTokens, static IReadOnlyDictionary> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNodesCredentials, value.NodesCredentials, null, null); + writer.WriteProperty(options, PropServiceAccount, value.ServiceAccount, null, null); + writer.WriteProperty(options, PropTokens, value.Tokens, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary> v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetServiceCredentialsResponseConverter))] public sealed partial class GetServiceCredentialsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,10 +106,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.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/_Generated/Api/Security/GetTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenRequest.g.cs index ee7fd7ce384..0061146438a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class GetTokenRequestParameters : RequestParameters /// public sealed partial class GetTokenRequest : PlainRequest { + [JsonConstructor] + internal GetTokenRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetToken; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs index 07fd75ec184..8e2fb752816 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs @@ -22,24 +22,118 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAccessToken = default; + LocalJsonValue propAuthentication = default; + LocalJsonValue propExpiresIn = default; + LocalJsonValue propKerberosAuthenticationResponseToken = default; + LocalJsonValue propRefreshToken = default; + LocalJsonValue propScope = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryReadProperty(ref reader, options, PropAccessToken, null)) + { + continue; + } + + if (propAuthentication.TryReadProperty(ref reader, options, PropAuthentication, null)) + { + continue; + } + + if (propExpiresIn.TryReadProperty(ref reader, options, PropExpiresIn, null)) + { + continue; + } + + if (propKerberosAuthenticationResponseToken.TryReadProperty(ref reader, options, PropKerberosAuthenticationResponseToken, null)) + { + continue; + } + + if (propRefreshToken.TryReadProperty(ref reader, options, PropRefreshToken, null)) + { + continue; + } + + if (propScope.TryReadProperty(ref reader, options, PropScope, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAuthentication, value.Authentication, null, null); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn, null, null); + writer.WriteProperty(options, PropKerberosAuthenticationResponseToken, value.KerberosAuthenticationResponseToken, null, null); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken, null, null); + writer.WriteProperty(options, PropScope, value.Scope, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.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/_Generated/Api/Security/GetUserPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesRequest.g.cs index 52d790b0458..56f309c92ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesRequest.g.cs @@ -55,6 +55,11 @@ public sealed partial class GetUserPrivilegesRequestParameters : RequestParamete /// public sealed partial class GetUserPrivilegesRequest : PlainRequest { + [JsonConstructor] + internal GetUserPrivilegesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetUserPrivileges; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs index 521ec2a00f5..c924a05c136 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propApplications = default; + LocalJsonValue> propCluster = default; + LocalJsonValue> propGlobal = default; + LocalJsonValue> propIndices = default; + LocalJsonValue> propRunAs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplications.TryReadProperty(ref reader, options, PropApplications, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propCluster.TryReadProperty(ref reader, options, PropCluster, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propGlobal.TryReadProperty(ref reader, options, PropGlobal, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propRunAs.TryReadProperty(ref reader, options, PropRunAs, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCluster, value.Cluster, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropGlobal, value.Global, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRunAs, value.RunAs, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Security/GetUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs index fa92cf1108f..55c663edcc9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs @@ -57,6 +57,11 @@ public GetUserProfileRequest(IReadOnlyCollection uid) : base(r => r.Requ { } + [JsonConstructor] + internal GetUserProfileRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGetUserProfile; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -65,6 +70,14 @@ public GetUserProfileRequest(IReadOnlyCollection uid) : base(r => r.Requ internal override string OperationName => "security.get_user_profile"; + /// + /// + /// A unique identifier for the user profile. + /// + /// + [JsonIgnore] + public ICollection Uid { get => P>("uid"); set => PR("uid", value); } + /// /// /// List of filters for the data field of the profile document. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs index 71e2118cb2b..0202182e52a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propErrors = default; + LocalJsonValue> propProfiles = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryReadProperty(ref reader, options, PropErrors, null)) + { + continue; + } + + if (propProfiles.TryReadProperty(ref reader, options, PropProfiles, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropProfiles, value.Profiles, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetUserProfileResponseConverter))] public sealed partial class GetUserProfileResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Security/GetUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs index 9c77e91e3f6..a4d7c8c4fa3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs @@ -50,6 +50,7 @@ public sealed partial class GetUserRequestParameters : RequestParameters /// public sealed partial class GetUserRequest : PlainRequest { + [JsonConstructor] public GetUserRequest() { } @@ -66,6 +67,14 @@ public GetUserRequest(IReadOnlyCollection "security.get_user"; + /// + /// + /// An identifier for the user. You can specify multiple usernames as a comma-separated list. If you omit this parameter, the API retrieves information about all users. + /// + /// + [JsonIgnore] + public ICollection? Username { get => P?>("username"); set => PO("username", value); } + /// /// /// If true will return the User Profile ID for a user, if any. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyRequest.g.cs index c09da87befc..283e2b7a98f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyRequest.g.cs @@ -59,6 +59,11 @@ public sealed partial class GrantApiKeyRequestParameters : RequestParameters /// public sealed partial class GrantApiKeyRequest : PlainRequest { + [JsonConstructor] + internal GrantApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityGrantApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs index 9644b9b2a5a..859d19df629 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryReadProperty(ref reader, options, PropApiKey, null)) + { + continue; + } + + if (propEncoded.TryReadProperty(ref reader, options, PropEncoded, null)) + { + continue; + } + + if (propExpiration.TryReadProperty(ref reader, options, PropExpiration, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropEncoded, value.Encoded, null, null); + writer.WriteProperty(options, PropExpiration, value.Expiration, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + 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/_Generated/Api/Security/HasPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs index 623c868da87..4c695bb4a21 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs @@ -44,6 +44,7 @@ public sealed partial class HasPrivilegesRequestParameters : RequestParameters /// public sealed partial class HasPrivilegesRequest : PlainRequest { + [JsonConstructor] public HasPrivilegesRequest() { } @@ -60,6 +61,13 @@ public HasPrivilegesRequest(Elastic.Clients.Elasticsearch.Name? user) : base(r = internal override string OperationName => "security.has_privileges"; + /// + /// + /// Username + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? User { get => P("user"); set => PO("user", value); } [JsonInclude, JsonPropertyName("application")] public ICollection? Application { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs index 024488da85d..df9c1907e4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs @@ -22,21 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue>>> propApplication = default; + LocalJsonValue> propCluster = default; + LocalJsonValue propHasAllRequested = default; + LocalJsonValue>> propIndex = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplication.TryReadProperty(ref reader, options, PropApplication, static IReadOnlyDictionary>> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static IReadOnlyDictionary> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)!)!)) + { + continue; + } + + if (propCluster.TryReadProperty(ref reader, options, PropCluster, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propHasAllRequested.TryReadProperty(ref reader, options, PropHasAllRequested, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, static IReadOnlyDictionary> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)!)) + { + continue; + } + + if (propUsername.TryReadProperty(ref reader, options, PropUsername, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>> v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary> v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)))); + writer.WriteProperty(options, PropCluster, value.Cluster, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHasAllRequested, value.HasAllRequested, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary> v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropUsername, value.Username, null, null); + 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/_Generated/Api/Security/HasPrivilegesUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileRequest.g.cs index 81f80132120..ab5698e0de6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class HasPrivilegesUserProfileRequestParameters : RequestP /// public sealed partial class HasPrivilegesUserProfileRequest : PlainRequest { + [JsonConstructor] + internal HasPrivilegesUserProfileRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityHasPrivilegesUserProfile; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs index 04b7b2fd847..046c76c6b0e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propErrors = default; + LocalJsonValue> propHasPrivilegeUids = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryReadProperty(ref reader, options, PropErrors, null)) + { + continue; + } + + if (propHasPrivilegeUids.TryReadProperty(ref reader, options, PropHasPrivilegeUids, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropHasPrivilegeUids, value.HasPrivilegeUids, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HasPrivilegesUserProfileResponseConverter))] public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResponse { /// @@ -36,7 +87,6 @@ public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResp /// requested privileges. This field is absent if empty. /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.HasPrivilegesUserProfileErrors? Errors { get; init; } /// @@ -45,6 +95,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/_Generated/Api/Security/InvalidateApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyRequest.g.cs index d648b5974ce..3369b87495b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyRequest.g.cs @@ -65,6 +65,11 @@ public sealed partial class InvalidateApiKeyRequestParameters : RequestParameter /// public sealed partial class InvalidateApiKeyRequest : PlainRequest { + [JsonConstructor] + internal InvalidateApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityInvalidateApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs index c46e96aaf8b..43713fa1ec4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propErrorCount = default; + LocalJsonValue?> propErrorDetails = default; + LocalJsonValue> propInvalidatedApiKeys = default; + LocalJsonValue> propPreviouslyInvalidatedApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryReadProperty(ref reader, options, PropErrorCount, null)) + { + continue; + } + + if (propErrorDetails.TryReadProperty(ref reader, options, PropErrorDetails, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propInvalidatedApiKeys.TryReadProperty(ref reader, options, PropInvalidatedApiKeys, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propPreviouslyInvalidatedApiKeys.TryReadProperty(ref reader, options, PropPreviouslyInvalidatedApiKeys, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropInvalidatedApiKeys, value.InvalidatedApiKeys, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPreviouslyInvalidatedApiKeys, value.PreviouslyInvalidatedApiKeys, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Security/InvalidateTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenRequest.g.cs index 4386ef53852..2601e0e8fa4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenRequest.g.cs @@ -50,6 +50,11 @@ public sealed partial class InvalidateTokenRequestParameters : RequestParameters /// public sealed partial class InvalidateTokenRequest : PlainRequest { + [JsonConstructor] + internal InvalidateTokenRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityInvalidateToken; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs index d014871850b..9f2505a376a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propErrorCount = default; + LocalJsonValue?> propErrorDetails = default; + LocalJsonValue propInvalidatedTokens = default; + LocalJsonValue propPreviouslyInvalidatedTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryReadProperty(ref reader, options, PropErrorCount, null)) + { + continue; + } + + if (propErrorDetails.TryReadProperty(ref reader, options, PropErrorDetails, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propInvalidatedTokens.TryReadProperty(ref reader, options, PropInvalidatedTokens, null)) + { + continue; + } + + if (propPreviouslyInvalidatedTokens.TryReadProperty(ref reader, options, PropPreviouslyInvalidatedTokens, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropInvalidatedTokens, value.InvalidatedTokens, null, null); + writer.WriteProperty(options, PropPreviouslyInvalidatedTokens, value.PreviouslyInvalidatedTokens, null, null); + 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/_Generated/Api/Security/PutPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs index 9ba02c01239..d98414969d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs @@ -47,8 +47,13 @@ public sealed partial class PutPrivilegesRequestParameters : RequestParameters /// Create or update application privileges. /// /// -public sealed partial class PutPrivilegesRequest : PlainRequest, ISelfSerializable +public sealed partial class PutPrivilegesRequest : PlainRequest { + [JsonConstructor] + internal PutPrivilegesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutPrivileges; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -65,11 +70,6 @@ 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) - { - JsonSerializer.Serialize(writer, Privileges, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs index e0713523d9f..c761e01dab1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs @@ -60,6 +60,11 @@ public PutRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = { } + [JsonConstructor] + internal PutRoleMappingRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutRoleMapping; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -68,6 +73,14 @@ public PutRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = internal override string OperationName => "security.put_role_mapping"; + /// + /// + /// Role-mapping name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs index c3a0d4a12ce..f25a04ff5c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCreated = default; + LocalJsonValue propRoleMapping = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryReadProperty(ref reader, options, PropCreated, null)) + { + continue; + } + + if (propRoleMapping.TryReadProperty(ref reader, options, PropRoleMapping, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRoleMapping, value.RoleMapping, null, null); + 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.Security.CreatedStatus RoleMapping { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs index 300912ec21c..a392c75fee2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs @@ -56,6 +56,11 @@ public PutRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Req { } + [JsonConstructor] + internal PutRoleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutRole; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -64,6 +69,14 @@ public PutRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Req internal override string OperationName => "security.put_role"; + /// + /// + /// The name of the role that is being created or updated. On Elasticsearch Serverless, the role name must begin with a letter or digit and can only contain letters, digits and the characters '_', '-', and '.'. Each role must have a unique name, as this will serve as the identifier for that role. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs index 6c6b329cdb4..26d7c16129d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propRole = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRole.TryReadProperty(ref reader, options, PropRole, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRoleResponseConverter))] public sealed partial class PutRoleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("role")] public Elastic.Clients.Elasticsearch.Security.CreatedStatus Role { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserRequest.g.cs index be4076b0394..3963fbf5a18 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserRequest.g.cs @@ -55,6 +55,11 @@ public PutUserRequest(Elastic.Clients.Elasticsearch.Username username) : base(r { } + [JsonConstructor] + internal PutUserRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutUser; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs index 5941437d1cc..9b47d5b35be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class PutUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + + public override PutUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryReadProperty(ref reader, options, PropCreated, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutUserResponse + { + Created = propCreated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutUserResponseConverter))] public sealed partial class PutUserResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool Created { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs index fdd42b6136d..a68abca662b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs @@ -55,98 +55,91 @@ 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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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.TryReadProperty(ref reader, options, PropFrom, null)) + { + 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.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); writer.WriteEndObject(); } } @@ -162,7 +155,8 @@ public override void Write(Utf8JsonWriter writer, QueryApiKeysRequest value, Jso [JsonConverter(typeof(QueryApiKeysRequestConverter))] public sealed partial class QueryApiKeysRequest : PlainRequest { - public QueryApiKeysRequest() + [JsonConstructor] + internal QueryApiKeysRequest() { } @@ -179,7 +173,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 +181,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 +188,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 +199,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 +208,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -231,7 +220,6 @@ public QueryApiKeysRequest() /// creation, expiration, invalidated, invalidation, username, realm, and metadata. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.ApiKeyQuery? Query { get; set; } /// @@ -239,7 +227,6 @@ public QueryApiKeysRequest() /// Search after definition /// /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -249,7 +236,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -258,8 +244,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.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs index 89b4746dbc8..2f24b1a30a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs @@ -22,10 +22,81 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAggregations = default; + LocalJsonValue> propApiKeys = default; + LocalJsonValue propCount = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propApiKeys.TryReadProperty(ref reader, options, PropApiKeys, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropApiKeys, value.ApiKeys, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCount, value.Count, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryApiKeysResponseConverter))] public sealed partial class QueryApiKeysResponse : ElasticsearchResponse { /// @@ -33,7 +104,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The aggregations result, if requested. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } /// @@ -41,7 +111,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// A list of API key information. /// /// - [JsonInclude, JsonPropertyName("api_keys")] public IReadOnlyCollection ApiKeys { get; init; } /// @@ -49,7 +118,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 +125,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/_Generated/Api/Security/QueryRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs index e55732256d7..02935f5f6c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs @@ -34,6 +34,84 @@ 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); + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + /// /// /// Find roles with a query. @@ -42,8 +120,14 @@ 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 { + [JsonConstructor] + internal QueryRoleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryRole; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -59,7 +143,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -72,7 +155,6 @@ public sealed partial class QueryRoleRequest : PlainRequestapplications.application, applications.privileges, applications.resources. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.RoleQuery? Query { get; set; } /// @@ -80,7 +162,6 @@ public sealed partial class QueryRoleRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -90,7 +171,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -99,8 +179,6 @@ public sealed partial class QueryRoleRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs index dab72c52d73..d300dadd807 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propRoles = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propRoles.TryReadProperty(ref reader, options, PropRoles, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRoles, value.Roles, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRoleResponseConverter))] public sealed partial class QueryRoleResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,6 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The list of roles. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection Roles { get; init; } /// @@ -49,6 +108,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/_Generated/Api/Security/QueryUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs index c5d98d22452..67de688c723 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs @@ -40,6 +40,84 @@ 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); + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + /// /// /// Find users with a query. @@ -49,8 +127,14 @@ public sealed partial class QueryUserRequestParameters : RequestParameters /// You can optionally filter the results with a query. /// /// +[JsonConverter(typeof(QueryUserRequestConverter))] public sealed partial class QueryUserRequest : PlainRequest { + [JsonConstructor] + internal QueryUserRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryUser; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -64,7 +148,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonIgnore] public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } /// @@ -74,7 +157,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -86,7 +168,6 @@ public sealed partial class QueryUserRequest : PlainRequestusername, roles, enabled /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.UserQuery? Query { get; set; } /// @@ -94,7 +175,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -104,7 +184,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -113,8 +192,6 @@ public sealed partial class QueryUserRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs index 36090081fc3..19712bf1c10 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue propTotal = default; + LocalJsonValue> propUsers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (propUsers.TryReadProperty(ref reader, options, PropUsers, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteProperty(options, PropUsers, value.Users, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryUserResponseConverter))] public sealed partial class QueryUserResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,6 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// The total number of users found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } /// @@ -49,6 +108,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/_Generated/Api/Security/SamlAuthenticateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateRequest.g.cs index 478b941c9d3..803b6beff5a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class SamlAuthenticateRequestParameters : RequestParameter /// public sealed partial class SamlAuthenticateRequest : PlainRequest { + [JsonConstructor] + internal SamlAuthenticateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlAuthenticate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs index 563c505d691..adc27270b6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs @@ -22,20 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAccessToken = default; + LocalJsonValue propExpiresIn = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRefreshToken = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryReadProperty(ref reader, options, PropAccessToken, null)) + { + continue; + } + + if (propExpiresIn.TryReadProperty(ref reader, options, PropExpiresIn, null)) + { + continue; + } + + if (propRealm.TryReadProperty(ref reader, options, PropRealm, null)) + { + continue; + } + + if (propRefreshToken.TryReadProperty(ref reader, options, PropRefreshToken, null)) + { + continue; + } + + if (propUsername.TryReadProperty(ref reader, options, PropUsername, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn, null, null); + writer.WriteProperty(options, PropRealm, value.Realm, null, null); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken, null, null); + writer.WriteProperty(options, PropUsername, value.Username, null, null); + 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/_Generated/Api/Security/SamlCompleteLogoutRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlCompleteLogoutRequest.g.cs index 9224bf81328..8254b20a885 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlCompleteLogoutRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlCompleteLogoutRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class SamlCompleteLogoutRequestParameters : RequestParamet /// public sealed partial class SamlCompleteLogoutRequest : PlainRequest { + [JsonConstructor] + internal SamlCompleteLogoutRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlCompleteLogout; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateRequest.g.cs index 987ee8fde44..061e1f4f273 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class SamlInvalidateRequestParameters : RequestParameters /// public sealed partial class SamlInvalidateRequest : PlainRequest { + [JsonConstructor] + internal SamlInvalidateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlInvalidate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs index afb8237ad22..df179954099 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propInvalidated = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInvalidated.TryReadProperty(ref reader, options, PropInvalidated, null)) + { + continue; + } + + if (propRealm.TryReadProperty(ref reader, options, PropRealm, null)) + { + continue; + } + + if (propRedirect.TryReadProperty(ref reader, options, PropRedirect, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRealm, value.Realm, null, null); + writer.WriteProperty(options, PropRedirect, value.Redirect, null, null); + 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/_Generated/Api/Security/SamlLogoutRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutRequest.g.cs index ffa0b19985c..fdd901f5c91 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class SamlLogoutRequestParameters : RequestParameters /// public sealed partial class SamlLogoutRequest : PlainRequest { + [JsonConstructor] + internal SamlLogoutRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlLogout; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs index 07e111b2a2b..efc2b12265f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRedirect.TryReadProperty(ref reader, options, PropRedirect, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Security/SamlPrepareAuthenticationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationRequest.g.cs index 9afa7d595d4..b0293a65e1f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationRequest.g.cs @@ -44,6 +44,11 @@ public sealed partial class SamlPrepareAuthenticationRequestParameters : Request /// public sealed partial class SamlPrepareAuthenticationRequest : PlainRequest { + [JsonConstructor] + internal SamlPrepareAuthenticationRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlPrepareAuthentication; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs index dd6dd3b5d56..758b1dd7160 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propId = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propRealm.TryReadProperty(ref reader, options, PropRealm, null)) + { + continue; + } + + if (propRedirect.TryReadProperty(ref reader, options, PropRedirect, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRealm, value.Realm, null, null); + writer.WriteProperty(options, PropRedirect, value.Redirect, null, null); + 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/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs index 009395c49bc..fb3613ec3d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs @@ -48,6 +48,11 @@ public SamlServiceProviderMetadataRequest(Elastic.Clients.Elasticsearch.Name rea { } + [JsonConstructor] + internal SamlServiceProviderMetadataRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlServiceProviderMetadata; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -55,6 +60,14 @@ public SamlServiceProviderMetadataRequest(Elastic.Clients.Elasticsearch.Name rea internal override bool SupportsBody => false; internal override string OperationName => "security.saml_service_provider_metadata"; + + /// + /// + /// The name of the SAML realm in Elasticsearch. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name RealmName { get => P("realm_name"); set => PR("realm_name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs index b64c8776d95..ad220022f86 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propMetadata = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMetadata.TryReadProperty(ref reader, options, PropMetadata, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs index c6596d47ecb..f9aea9d95ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs @@ -34,6 +34,74 @@ 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); + LocalJsonValue?> propData = default; + LocalJsonValue propHint = default; + LocalJsonValue propName = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryReadProperty(ref reader, options, PropData, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propHint.TryReadProperty(ref reader, options, PropHint, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropHint, value.Hint, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteEndObject(); + } +} + /// /// /// Suggest a user profile. @@ -42,8 +110,14 @@ 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 { + [JsonConstructor] + internal SuggestUserProfilesRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySuggestUserProfiles; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -60,8 +134,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestdata content. /// /// - [JsonInclude, JsonPropertyName("data")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Data { get; set; } /// @@ -72,7 +144,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestname field query. /// /// - [JsonInclude, JsonPropertyName("hint")] public Elastic.Clients.Elasticsearch.Security.Hint? Hint { get; set; } /// @@ -81,7 +152,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestusername, full_name, and email. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; set; } /// @@ -89,7 +159,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("size")] public long? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs index 9ab634abb11..e4dff7a5991 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propProfiles = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propProfiles.TryReadProperty(ref reader, options, PropProfiles, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + 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.Security.TotalUserProfiles Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs index 15a488a199c..787dd8a456b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs @@ -60,6 +60,11 @@ public UpdateApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re { } + [JsonConstructor] + internal UpdateApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityUpdateApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -68,6 +73,14 @@ public UpdateApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override string OperationName => "security.update_api_key"; + /// + /// + /// The ID of the API key to update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Expiration time for the API key. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs index ceeb922e33e..5a1bc3d04e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateApiKeyResponseConverter))] public sealed partial class UpdateApiKeyResponse : ElasticsearchResponse { /// @@ -34,6 +75,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/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs index c93f01a473e..b916391449e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs @@ -48,6 +48,11 @@ public UpdateCrossClusterApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : ba { } + [JsonConstructor] + internal UpdateCrossClusterApiKeyRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityUpdateCrossClusterApiKey; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -56,6 +61,14 @@ public UpdateCrossClusterApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "security.update_cross_cluster_api_key"; + /// + /// + /// The ID of the cross-cluster API key to update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The access to be granted to this API key. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs index d884f62166e..eda60cc0640 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class UpdateCrossClusterApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpdateCrossClusterApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateCrossClusterApiKeyResponse + { + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateCrossClusterApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropUpdated, value.Updated, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateCrossClusterApiKeyResponseConverter))] public sealed partial class UpdateCrossClusterApiKeyResponse : ElasticsearchResponse { /// @@ -34,6 +75,5 @@ public sealed partial class UpdateCrossClusterApiKeyResponse : ElasticsearchResp /// 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/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs index 98048ccd890..0f44fe1363d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs @@ -70,6 +70,11 @@ public UpdateUserProfileDataRequest(string uid) : base(r => r.Required("uid", ui { } + [JsonConstructor] + internal UpdateUserProfileDataRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityUpdateUserProfileData; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -78,6 +83,14 @@ public UpdateUserProfileDataRequest(string uid) : base(r => r.Required("uid", ui internal override string OperationName => "security.update_user_profile_data"; + /// + /// + /// A unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// Only perform the operation if the document has this primary term. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs index 1d47f41e31d..a88a2ab3a54 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateUserProfileDataResponseConverter))] public sealed partial class UpdateUserProfileDataResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs index 3f7be7b5baa..945691ad4bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs @@ -59,6 +59,11 @@ public CleanupRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base( { } + [JsonConstructor] + internal CleanupRepositoryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotCleanupRepository; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -67,6 +72,14 @@ public CleanupRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base( internal override string OperationName => "snapshot.cleanup_repository"; + /// + /// + /// Snapshot repository to clean up. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs index 7a5a0dd0e26..afa8b354db7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResults.TryReadProperty(ref reader, options, PropResults, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CleanupRepositoryResponseConverter))] public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +74,5 @@ public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse /// Statistics for cleanup operations. /// /// - [JsonInclude, JsonPropertyName("results")] public Elastic.Clients.Elasticsearch.Snapshot.CleanupRepositoryResults Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs index 69c10ac78c7..19263226724 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs @@ -53,6 +53,11 @@ public CloneSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elast { } + [JsonConstructor] + internal CloneSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotClone; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -61,6 +66,30 @@ public CloneSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elast internal override string OperationName => "snapshot.clone"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// The name of the snapshot to clone from + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + + /// + /// + /// The name of the cloned snapshot to create + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name TargetSnapshot { get => P("target_snapshot"); set => PR("target_snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs index 28a6abe2a04..d2ee8d42d39 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloneSnapshotResponseConverter))] public sealed partial class CloneSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs index bba5de0492f..754ac938f4f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs @@ -54,6 +54,19 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter public bool? Verify { get => Q("verify"); set => Q("verify", value); } } +internal sealed partial class CreateRepositoryRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + public override CreateRepositoryRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return new CreateRepositoryRequest { Repository = reader.ReadValue(options, null) }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateRepositoryRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteValue(options, value.Repository, null); + } +} + /// /// /// Create or update a snapshot repository. @@ -62,12 +75,18 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter /// Ensure there are no cluster blocks (for example, cluster.blocks.read_only and clsuter.blocks.read_only_allow_delete settings) that prevent write access. /// /// -public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfSerializable +[JsonConverter(typeof(CreateRepositoryRequestConverter))] +public sealed partial class CreateRepositoryRequest : PlainRequest { public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("repository", name)) { } + [JsonConstructor] + internal CreateRepositoryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotCreateRepository; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -76,12 +95,18 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "snapshot.create_repository"; + /// + /// + /// A repository name + /// + /// + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -89,7 +114,6 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r /// Explicit operation timeout /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -97,15 +121,8 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r /// Whether to verify the repository after creation /// /// - [JsonIgnore] public bool? Verify { get => Q("verify"); set => Q("verify", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Snapshot.IRepository Repository { get; set; } - - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - JsonSerializer.Serialize(writer, Repository, options); - } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs index cfe979a738f..90fa7502a8d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateRepositoryResponseConverter))] public sealed partial class CreateRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs index 974b6350300..9d7b0d347da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs @@ -59,6 +59,11 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas { } + [JsonConstructor] + internal CreateSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotCreate; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -67,6 +72,22 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas internal override string OperationName => "snapshot.create"; + /// + /// + /// Repository for the snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// Name of the snapshot. Must be unique in the repository. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs index 3afcb6e1a68..db27cfb46f5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAccepted = default; + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryReadProperty(ref reader, options, PropAccepted, null)) + { + continue; + } + + if (propSnapshot.TryReadProperty(ref reader, options, PropSnapshot, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSnapshot, value.Snapshot, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateSnapshotResponseConverter))] public sealed partial class CreateSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +84,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 +91,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.Snapshot.SnapshotInfo? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs index bda787380fe..7758037e1b1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs @@ -60,6 +60,11 @@ public DeleteRepositoryRequest(Elastic.Clients.Elasticsearch.Names name) : base( { } + [JsonConstructor] + internal DeleteRepositoryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotDeleteRepository; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -68,6 +73,14 @@ public DeleteRepositoryRequest(Elastic.Clients.Elasticsearch.Names name) : base( internal override string OperationName => "snapshot.delete_repository"; + /// + /// + /// Name of the snapshot repository to unregister. Wildcard (*) patterns are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs index 0c043369220..ebdfd47ee29 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRepositoryResponseConverter))] public sealed partial class DeleteRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs index 6b478e4cbff..70975462cdc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs @@ -51,6 +51,11 @@ public DeleteSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas { } + [JsonConstructor] + internal DeleteSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotDelete; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -59,6 +64,22 @@ public DeleteSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas internal override string OperationName => "snapshot.delete"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// A comma-separated list of snapshot names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs index e1a69227318..42ce07b9845 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSnapshotResponseConverter))] public sealed partial class DeleteSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs index a6279cf9d40..e13ae213da6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs @@ -54,6 +54,7 @@ public sealed partial class GetRepositoryRequestParameters : RequestParameters /// public sealed partial class GetRepositoryRequest : PlainRequest { + [JsonConstructor] public GetRepositoryRequest() { } @@ -70,6 +71,14 @@ public GetRepositoryRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r internal override string OperationName => "snapshot.get_repository"; + /// + /// + /// A comma-separated list of repository names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("repository"); set => PO("repository", value); } + /// /// /// Return local information, do not retrieve the state from master node (default: false) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs index a920c821cac..fe95674d7e0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs @@ -135,6 +135,11 @@ public GetSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic { } + [JsonConstructor] + internal GetSnapshotRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -143,6 +148,34 @@ public GetSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic internal override string OperationName => "snapshot.get"; + /// + /// + /// Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*). + /// + /// + /// + /// + /// To get information about all snapshots in a registered repository, use a wildcard (*) or _all. + /// + /// + /// + /// + /// To get information about any snapshots that are currently running, use _current. + /// + /// + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Offset identifier to start pagination from as returned by the next field in the response body. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs index 929c06311cc..ac5a21e2517 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs @@ -22,10 +22,81 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class GetSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + 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); + LocalJsonValue propRemaining = default; + LocalJsonValue?> propResponses = default; + LocalJsonValue?> propSnapshots = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRemaining.TryReadProperty(ref reader, options, PropRemaining, null)) + { + continue; + } + + if (propResponses.TryReadProperty(ref reader, options, PropResponses, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSnapshots.TryReadProperty(ref reader, options, PropSnapshots, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 + { + 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, PropRemaining, value.Remaining, null, null); + writer.WriteProperty(options, PropResponses, value.Responses, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSnapshots, value.Snapshots, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSnapshotResponseConverter))] public sealed partial class GetSnapshotResponse : ElasticsearchResponse { /// @@ -33,11 +104,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; } /// @@ -45,6 +113,5 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// The total number of snapshots that match the request when ignoring 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/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs index f48895454de..d51fc20c9e4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs @@ -155,6 +155,11 @@ public RepositoryVerifyIntegrityRequest(Elastic.Clients.Elasticsearch.Names name { } + [JsonConstructor] + internal RepositoryVerifyIntegrityRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotRepositoryVerifyIntegrity; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -163,6 +168,14 @@ public RepositoryVerifyIntegrityRequest(Elastic.Clients.Elasticsearch.Names name internal override string OperationName => "snapshot.repository_verify_integrity"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Number of threads to use for reading blob contents diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs index 73de6d5abec..2293e6d4487 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs @@ -79,6 +79,11 @@ public RestoreRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Cli { } + [JsonConstructor] + internal RestoreRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotRestore; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -87,6 +92,22 @@ public RestoreRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Cli internal override string OperationName => "snapshot.restore"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// A snapshot name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs index 1bf5db7079d..72a86cb0157 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAccepted = default; + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryReadProperty(ref reader, options, PropAccepted, null)) + { + continue; + } + + if (propSnapshot.TryReadProperty(ref reader, options, PropSnapshot, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSnapshot, value.Snapshot, null, null); + 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.Snapshot.SnapshotRestore? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs index 11e6df51119..ea4ae5aedf7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs @@ -66,6 +66,7 @@ public sealed partial class SnapshotStatusRequestParameters : RequestParameters /// public sealed partial class SnapshotStatusRequest : PlainRequest { + [JsonConstructor] public SnapshotStatusRequest() { } @@ -86,6 +87,22 @@ public SnapshotStatusRequest(Elastic.Clients.Elasticsearch.Name? repository, Ela internal override string OperationName => "snapshot.status"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Repository { get => P("repository"); set => PO("repository", value); } + + /// + /// + /// A comma-separated list of snapshot names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Snapshot { get => P("snapshot"); set => PO("snapshot", value); } + /// /// /// Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs index e77aa967106..62d772c3179 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshots.TryReadProperty(ref reader, options, PropSnapshots, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs index e6100f9e2f9..2c634049b72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs @@ -59,6 +59,11 @@ public VerifyRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r { } + [JsonConstructor] + internal VerifyRepositoryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotVerifyRepository; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -67,6 +72,14 @@ public VerifyRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "snapshot.verify_repository"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs index 8ebe48523d7..7ecbf589ef8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VerifyRepositoryResponseConverter))] public sealed partial class VerifyRepositoryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs index e50ac965692..710fe86a61c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs @@ -47,6 +47,11 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : bas { } + [JsonConstructor] + internal DeleteLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementDeleteLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -54,6 +59,14 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : bas internal override bool SupportsBody => false; internal override string OperationName => "slm.delete_lifecycle"; + + /// + /// + /// The id of the snapshot lifecycle policy to remove + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs index ca9286d517a..46eaea28cb4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLifecycleResponseConverter))] public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs index 46c763acd3a..5accf1e4baf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs @@ -47,6 +47,11 @@ public ExecuteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : ba { } + [JsonConstructor] + internal ExecuteLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementExecuteLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -54,6 +59,14 @@ public ExecuteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : ba internal override bool SupportsBody => false; internal override string OperationName => "slm.execute_lifecycle"; + + /// + /// + /// The id of the snapshot lifecycle policy to be executed + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs index ef39b567457..0a52dfea833 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propSnapshotName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshotName.TryReadProperty(ref reader, options, PropSnapshotName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionRequest.g.cs index 14f759460ca..ca371c74ee2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionRequest.g.cs @@ -43,6 +43,11 @@ public sealed partial class ExecuteRetentionRequestParameters : RequestParameter /// public sealed partial class ExecuteRetentionRequest : PlainRequest { + [JsonConstructor] + internal ExecuteRetentionRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementExecuteRetention; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs index 42e6e3e5727..6c1574e88d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecuteRetentionResponseConverter))] public sealed partial class ExecuteRetentionResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs index e647bd33bb8..a8c75fe4dd4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs @@ -42,6 +42,7 @@ public sealed partial class GetLifecycleRequestParameters : RequestParameters /// public sealed partial class GetLifecycleRequest : PlainRequest { + [JsonConstructor] public GetLifecycleRequest() { } @@ -57,6 +58,14 @@ public GetLifecycleRequest(Elastic.Clients.Elasticsearch.Names? policyId) : base internal override bool SupportsBody => false; internal override string OperationName => "slm.get_lifecycle"; + + /// + /// + /// Comma-separated list of snapshot lifecycle policies to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? PolicyId { get => P("policy_id"); set => PO("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusRequest.g.cs index 3b0fc096ab6..68d831ee252 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusRequest.g.cs @@ -41,6 +41,11 @@ public sealed partial class GetSlmStatusRequestParameters : RequestParameters /// public sealed partial class GetSlmStatusRequest : PlainRequest { + [JsonConstructor] + internal GetSlmStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementGetStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs index c2cc6418284..edd0379630d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propOperationMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOperationMode.TryReadProperty(ref reader, options, PropOperationMode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSlmStatusResponseConverter))] public sealed partial class GetSlmStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("operation_mode")] public Elastic.Clients.Elasticsearch.LifecycleOperationMode OperationMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsRequest.g.cs index 183295795da..3544c75856c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class GetStatsRequestParameters : RequestParameters /// public sealed partial class GetStatsRequest : PlainRequest { + [JsonConstructor] + internal GetStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementGetStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs index 7174da48a8a..b2ace039d00 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs @@ -22,30 +22,151 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propPolicyStats = default; + LocalJsonValue propRetentionDeletionTime = default; + LocalJsonValue propRetentionDeletionTimeMillis = default; + LocalJsonValue propRetentionFailed = default; + LocalJsonValue propRetentionRuns = default; + LocalJsonValue propRetentionTimedOut = default; + LocalJsonValue propTotalSnapshotDeletionFailures = default; + LocalJsonValue propTotalSnapshotsDeleted = default; + LocalJsonValue propTotalSnapshotsFailed = default; + LocalJsonValue propTotalSnapshotsTaken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicyStats.TryReadProperty(ref reader, options, PropPolicyStats, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propRetentionDeletionTime.TryReadProperty(ref reader, options, PropRetentionDeletionTime, null)) + { + continue; + } + + if (propRetentionDeletionTimeMillis.TryReadProperty(ref reader, options, PropRetentionDeletionTimeMillis, null)) + { + continue; + } + + if (propRetentionFailed.TryReadProperty(ref reader, options, PropRetentionFailed, null)) + { + continue; + } + + if (propRetentionRuns.TryReadProperty(ref reader, options, PropRetentionRuns, null)) + { + continue; + } + + if (propRetentionTimedOut.TryReadProperty(ref reader, options, PropRetentionTimedOut, null)) + { + continue; + } + + if (propTotalSnapshotDeletionFailures.TryReadProperty(ref reader, options, PropTotalSnapshotDeletionFailures, null)) + { + continue; + } + + if (propTotalSnapshotsDeleted.TryReadProperty(ref reader, options, PropTotalSnapshotsDeleted, null)) + { + continue; + } + + if (propTotalSnapshotsFailed.TryReadProperty(ref reader, options, PropTotalSnapshotsFailed, null)) + { + continue; + } + + if (propTotalSnapshotsTaken.TryReadProperty(ref reader, options, PropTotalSnapshotsTaken, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRetentionDeletionTime, value.RetentionDeletionTime, null, null); + writer.WriteProperty(options, PropRetentionDeletionTimeMillis, value.RetentionDeletionTimeMillis, null, null); + writer.WriteProperty(options, PropRetentionFailed, value.RetentionFailed, null, null); + writer.WriteProperty(options, PropRetentionRuns, value.RetentionRuns, null, null); + writer.WriteProperty(options, PropRetentionTimedOut, value.RetentionTimedOut, null, null); + writer.WriteProperty(options, PropTotalSnapshotDeletionFailures, value.TotalSnapshotDeletionFailures, null, null); + writer.WriteProperty(options, PropTotalSnapshotsDeleted, value.TotalSnapshotsDeleted, null, null); + writer.WriteProperty(options, PropTotalSnapshotsFailed, value.TotalSnapshotsFailed, null, null); + writer.WriteProperty(options, PropTotalSnapshotsTaken, value.TotalSnapshotsTaken, null, null); + 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.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/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs index 865a2baf563..c2ed4da0c5d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs @@ -61,6 +61,11 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : base(r { } + [JsonConstructor] + internal PutLifecycleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementPutLifecycle; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -69,6 +74,14 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : base(r internal override string OperationName => "slm.put_lifecycle"; + /// + /// + /// The identifier for the snapshot lifecycle policy you want to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs index e9eaecf826f..dd17d8922de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutLifecycleResponseConverter))] public sealed partial class PutLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/SnapshotLifecycleManagement/StartSlmRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmRequest.g.cs index f45719cc0a0..97cbb96efd3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmRequest.g.cs @@ -43,6 +43,11 @@ public sealed partial class StartSlmRequestParameters : RequestParameters /// public sealed partial class StartSlmRequest : PlainRequest { + [JsonConstructor] + internal StartSlmRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementStart; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs index 8ebc963e7ac..a53be40fa86 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartSlmResponseConverter))] public sealed partial class StartSlmResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/SnapshotLifecycleManagement/StopSlmRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmRequest.g.cs index 4f8e240975d..402006294b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmRequest.g.cs @@ -49,6 +49,11 @@ public sealed partial class StopSlmRequestParameters : RequestParameters /// public sealed partial class StopSlmRequest : PlainRequest { + [JsonConstructor] + internal StopSlmRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SnapshotLifecycleManagementStop; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs index c7f3fd2cc66..b4f61e61e3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopSlmResponseConverter))] public sealed partial class StopSlmResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Sql/ClearCursorRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorRequest.g.cs index 3f9c11570d2..952cf9ad53b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorRequest.g.cs @@ -41,6 +41,11 @@ public sealed partial class ClearCursorRequestParameters : RequestParameters /// public sealed partial class ClearCursorRequest : PlainRequest { + [JsonConstructor] + internal ClearCursorRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlClearCursor; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs index a57592eeeb5..e06ff5728d5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSucceeded.TryReadProperty(ref reader, options, PropSucceeded, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Api/Sql/DeleteAsyncRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs index d306d8916d2..0aa888d1e04 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs @@ -47,6 +47,11 @@ public DeleteAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req { } + [JsonConstructor] + internal DeleteAsyncRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlDeleteAsync; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -54,6 +59,14 @@ public DeleteAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req internal override bool SupportsBody => false; internal override string OperationName => "sql.delete_async"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs index 29fa3e3e14d..23f5851cc98 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncResponseConverter))] public sealed partial class DeleteAsyncResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Sql/GetAsyncRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs index a725dcd4bd3..6be135f0630 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs @@ -76,6 +76,11 @@ public GetAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir { } + [JsonConstructor] + internal GetAsyncRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlGetAsync; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -84,6 +89,14 @@ public GetAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir internal override string OperationName => "sql.get_async"; + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Separator for CSV results. The API only supports this parameter for CSV responses. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs index 9762bd7bd96..665b31151e1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propColumns = default; + LocalJsonValue propCursor = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryReadProperty(ref reader, options, PropColumns, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCursor.TryReadProperty(ref reader, options, PropCursor, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCursor, value.Cursor, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncResponseConverter))] public sealed partial class GetAsyncResponse : ElasticsearchResponse { /// @@ -33,7 +114,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 +122,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 +131,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -64,7 +142,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 +152,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/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs index cd754c0e812..bc325bb913c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs @@ -46,6 +46,11 @@ public GetAsyncStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. { } + [JsonConstructor] + internal GetAsyncStatusRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlGetAsyncStatus; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,14 @@ public GetAsyncStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override bool SupportsBody => false; internal override string OperationName => "sql.get_async_status"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs index 8dd9a09e22b..45f3ff988c2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs @@ -22,10 +22,101 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryReadProperty(ref reader, options, PropCompletionStatus, null)) + { + continue; + } + + if (propExpirationTimeInMillis.TryReadProperty(ref reader, options, PropExpirationTimeInMillis, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncStatusResponseConverter))] public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse { /// @@ -33,7 +124,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 +132,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 +139,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -61,7 +149,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// timeout. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -69,7 +156,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 +164,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/_Generated/Api/Sql/QueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs index a45bfdcc1cd..7cb9b7adfbf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs @@ -48,6 +48,11 @@ public sealed partial class QueryRequestParameters : RequestParameters /// public sealed partial class QueryRequest : PlainRequest { + [JsonConstructor] + internal QueryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlQuery; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs index 68a8c3c72ca..85a49e8c026 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs @@ -22,10 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propColumns = default; + LocalJsonValue propCursor = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryReadProperty(ref reader, options, PropColumns, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCursor.TryReadProperty(ref reader, options, PropCursor, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIsPartial.TryReadProperty(ref reader, options, PropIsPartial, null)) + { + continue; + } + + if (propIsRunning.TryReadProperty(ref reader, options, PropIsRunning, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCursor, value.Cursor, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIsPartial, value.IsPartial, null, null); + writer.WriteProperty(options, PropIsRunning, value.IsRunning, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryResponseConverter))] public sealed partial class QueryResponse : ElasticsearchResponse { /// @@ -33,7 +114,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 +122,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 +131,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -64,7 +142,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 +152,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/_Generated/Api/Sql/TranslateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateRequest.g.cs index 33dd98cbf08..3a4d1bae220 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateRequest.g.cs @@ -42,6 +42,11 @@ public sealed partial class TranslateRequestParameters : RequestParameters /// public sealed partial class TranslateRequest : PlainRequest { + [JsonConstructor] + internal TranslateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SqlTranslate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs index 583441e33fb..0b86aa62b3b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs @@ -22,23 +22,107 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + 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.QueryDsl.Query? Query { get; init; } - [JsonInclude, JsonPropertyName("size")] public long? Size { get; init; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public IReadOnlyCollection? Sort { get; init; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs index 8468d27085d..19ac1c9e5d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs @@ -45,6 +45,11 @@ public DeleteSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.R { } + [JsonConstructor] + internal DeleteSynonymRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsDeleteSynonym; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -52,6 +57,14 @@ public DeleteSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.R internal override bool SupportsBody => false; internal override string OperationName => "synonyms.delete_synonym"; + + /// + /// + /// The id of the synonyms set to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs index 484ef271a05..a464dd766d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymResponseConverter))] public sealed partial class DeleteSynonymResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs index 9bc1264b7ef..7a7404a35ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs @@ -46,6 +46,11 @@ public DeleteSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic. { } + [JsonConstructor] + internal DeleteSynonymRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsDeleteSynonymRule; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -53,6 +58,22 @@ public DeleteSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic. internal override bool SupportsBody => false; internal override string OperationName => "synonyms.delete_synonym_rule"; + + /// + /// + /// The id of the synonym rule to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to be updated + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs index 7a128cafa53..f04d9d801c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryReadProperty(ref reader, options, PropReloadAnalyzersDetails, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymRuleResponseConverter))] public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +85,6 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +92,5 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs index 4a03450e469..7c108657f1a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs @@ -58,6 +58,11 @@ public GetSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requ { } + [JsonConstructor] + internal GetSynonymRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsGetSynonym; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -66,6 +71,14 @@ public GetSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requ internal override string OperationName => "synonyms.get_synonym"; + /// + /// + /// "The id of the synonyms set to be retrieved + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Starting offset for query rules to be retrieved diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs index e61b17766d2..9ddac373af6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propSynonymsSet.TryReadProperty(ref reader, options, PropSynonymsSet, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSynonymsSet, value.SynonymsSet, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs index 55894c24e13..1d042c3d3d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs @@ -46,6 +46,11 @@ public GetSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli { } + [JsonConstructor] + internal GetSynonymRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsGetSynonymRule; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -53,6 +58,22 @@ public GetSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli internal override bool SupportsBody => false; internal override string OperationName => "synonyms.get_synonym_rule"; + + /// + /// + /// The id of the synonym rule to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to retrieve the synonym rule from + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs index a6fc0854ce0..44532e2cf01 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propId = default; + LocalJsonValue propSynonyms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propSynonyms.TryReadProperty(ref reader, options, PropSynonyms, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropSynonyms, value.Synonyms, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymRuleResponseConverter))] public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse { /// @@ -33,7 +84,6 @@ public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse /// Synonym Rule identifier /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -41,6 +91,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/_Generated/Api/Synonyms/GetSynonymsSetsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsRequest.g.cs index ff263268dcd..ee912202771 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsRequest.g.cs @@ -55,6 +55,11 @@ public sealed partial class GetSynonymsSetsRequestParameters : RequestParameters /// public sealed partial class GetSynonymsSetsRequest : PlainRequest { + [JsonConstructor] + internal GetSynonymsSetsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsGetSynonymsSets; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs index 62143e3725b..cb7cafb862c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propResults.TryReadProperty(ref reader, options, PropResults, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropResults, value.Results, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/Synonyms/PutSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs index ebde087aa42..5a1dcb81802 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs @@ -34,6 +34,44 @@ 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); + LocalJsonValue> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSynonymsSet.TryReadProperty(ref reader, options, PropSynonymsSet, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a synonym set. @@ -41,12 +79,18 @@ 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.Id id) : base(r => r.Required("id", id)) { } + [JsonConstructor] + internal PutSynonymRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsPutSynonym; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -55,13 +99,18 @@ public PutSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requ internal override string OperationName => "synonyms.put_synonym"; + /// + /// + /// The id of the synonyms set to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The synonym set information to update /// /// - [JsonInclude, JsonPropertyName("synonyms_set")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Synonyms.SynonymRule))] public ICollection SynonymsSet { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs index 21b5b6c1093..1831bd4516b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryReadProperty(ref reader, options, PropReloadAnalyzersDetails, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymResponseConverter))] public sealed partial class PutSynonymResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs index 30b670af3d5..032169df427 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs @@ -46,6 +46,11 @@ public PutSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli { } + [JsonConstructor] + internal PutSynonymRuleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.SynonymsPutSynonymRule; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -54,6 +59,21 @@ public PutSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli internal override string OperationName => "synonyms.put_synonym_rule"; + /// + /// + /// The id of the synonym rule to be updated or created + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to be updated with the synonym rule + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } [JsonInclude, JsonPropertyName("synonyms")] public string Synonyms { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs index 652aebc8333..57a8598ad12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs @@ -22,10 +22,61 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryReadProperty(ref reader, options, PropReloadAnalyzersDetails, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymRuleResponseConverter))] public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +85,6 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +92,5 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs index ecf9f2c38c1..3c721e16380 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs @@ -76,6 +76,7 @@ public sealed partial class CancelRequestParameters : RequestParameters /// public sealed partial class CancelRequest : PlainRequest { + [JsonConstructor] public CancelRequest() { } @@ -92,6 +93,14 @@ public CancelRequest(Elastic.Clients.Elasticsearch.TaskId? taskId) : base(r => r internal override string OperationName => "tasks.cancel"; + /// + /// + /// ID of the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.TaskId? TaskId { get => P("task_id"); set => PO("task_id", value); } + /// /// /// Comma-separated list or wildcard expression of actions used to limit the request. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs index 42734dac9ee..0d9eb9f0ca2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs @@ -22,13 +22,83 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class CancelResponseConverter : 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 CancelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryReadProperty(ref reader, options, PropNodeFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propTaskFailures.TryReadProperty(ref reader, options, PropTaskFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTasks.TryReadProperty(ref reader, options, PropTasks, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CancelResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CancelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTasks, value.Tasks, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CancelResponseConverter))] public sealed partial class CancelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +106,7 @@ public sealed partial class CancelResponse : ElasticsearchResponse /// 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 +115,5 @@ public sealed partial class CancelResponse : ElasticsearchResponse /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs index 543a2fadcd0..eb7f2576c1d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs @@ -60,6 +60,11 @@ public GetTasksRequest(Elastic.Clients.Elasticsearch.Id taskId) : base(r => r.Re { } + [JsonConstructor] + internal GetTasksRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TasksGet; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -68,6 +73,14 @@ public GetTasksRequest(Elastic.Clients.Elasticsearch.Id taskId) : base(r => r.Re internal override string OperationName => "tasks.get"; + /// + /// + /// ID of the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs index cd9c953e47f..6f17ecc2f1d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class GetTasksResponseConverter : 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 PropError = System.Text.Json.JsonEncodedText.Encode("error"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + + public override GetTasksResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompleted = default; + LocalJsonValue propError = default; + LocalJsonValue propResponse = default; + LocalJsonValue propTask = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompleted.TryReadProperty(ref reader, options, PropCompleted, null)) + { + continue; + } + + if (propError.TryReadProperty(ref reader, options, PropError, null)) + { + continue; + } + + if (propResponse.TryReadProperty(ref reader, options, PropResponse, null)) + { + continue; + } + + if (propTask.TryReadProperty(ref reader, options, PropTask, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTasksResponse + { + Completed = propCompleted.Value +, + Error = propError.Value +, + Response = propResponse.Value +, + Task = propTask.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTasksResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompleted, value.Completed, null, null); + writer.WriteProperty(options, PropError, value.Error, null, null); + writer.WriteProperty(options, PropResponse, value.Response, null, null); + writer.WriteProperty(options, PropTask, value.Task, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTasksResponseConverter))] public sealed partial class GetTasksResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("completed")] public bool Completed { get; init; } - [JsonInclude, JsonPropertyName("error")] public Elastic.Clients.Elasticsearch.ErrorCause? Error { get; init; } - [JsonInclude, JsonPropertyName("response")] public object? Response { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfo Task { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListRequest.g.cs index f20af93fc1b..6239488107b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListRequest.g.cs @@ -98,6 +98,11 @@ public sealed partial class ListRequestParameters : RequestParameters /// public sealed partial class ListRequest : PlainRequest { + [JsonConstructor] + internal ListRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TasksList; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs index 6eec10fe844..23a5fd229cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs @@ -22,13 +22,83 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class ListResponseConverter : 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 ListResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryReadProperty(ref reader, options, PropNodeFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propTaskFailures.TryReadProperty(ref reader, options, PropTaskFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTasks.TryReadProperty(ref reader, options, PropTasks, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTasks, value.Tasks, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListResponseConverter))] public sealed partial class ListResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +106,7 @@ public sealed partial class ListResponse : ElasticsearchResponse /// 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 +115,5 @@ public sealed partial class ListResponse : ElasticsearchResponse /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs index f9052ff3303..e6902af173d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs @@ -112,6 +112,81 @@ public sealed partial class TermVectorsRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDoc = default; + LocalJsonValue propFilter = default; + LocalJsonValue?> propPerFieldAnalyzer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryReadProperty(ref reader, options, PropDoc, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, null)) + { + continue; + } + + if (propPerFieldAnalyzer.TryReadProperty(ref reader, options, PropPerFieldAnalyzer, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropFilter, value.Filter, null, null); + writer.WriteProperty(options, PropPerFieldAnalyzer, value.PerFieldAnalyzer, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + 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 +195,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.IndexName index, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", index).Optional("id", id)) @@ -130,6 +206,11 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( { } + [JsonConstructor] + public TermVectorsRequest() : this(typeof(TDocument)) + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceTermvectors; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -138,13 +219,26 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override string OperationName => "termvectors"; + /// + /// + /// Unique identifier of the document. + /// + /// + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in the statistics. /// 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.Fields? Fields { get => Q("fields"); set => Q("fields", value); } /// @@ -152,7 +246,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// 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 +253,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term offsets. /// /// - [JsonIgnore] public bool? Offsets { get => Q("offsets"); set => Q("offsets", value); } /// @@ -168,7 +260,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term payloads. /// /// - [JsonIgnore] public bool? Payloads { get => Q("payloads"); set => Q("payloads", value); } /// @@ -176,7 +267,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term positions. /// /// - [JsonIgnore] public bool? Positions { get => Q("positions"); set => Q("positions", value); } /// @@ -185,7 +275,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Random by default. /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -193,7 +282,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// 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 +289,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -209,7 +296,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// 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 +303,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, returns the document version as part of a hit. /// /// - [JsonIgnore] public long? Version { get => Q("version"); set => Q("version", value); } /// @@ -225,7 +310,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Specific version type. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } /// @@ -233,8 +317,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// 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 +324,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Core.TermVectors.Filter? Filter { get; set; } /// @@ -250,7 +331,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Overrides the default per-field analyzer. /// /// - [JsonInclude, JsonPropertyName("per_field_analyzer")] public IDictionary? PerFieldAnalyzer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs index 530b3a6d741..31f6d9128a2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs @@ -22,23 +22,107 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propTermVectors = default; + LocalJsonValue propTook = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propTermVectors.TryReadProperty(ref reader, options, PropTermVectors, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropTermVectors, value.TermVectors, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.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/_Generated/Api/TermsEnumRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs index 60b90b70370..7329c2e00b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs @@ -56,6 +56,11 @@ public TermsEnumRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r { } + [JsonConstructor] + internal TermsEnumRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceTermsEnum; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -64,6 +69,14 @@ public TermsEnumRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r internal override string OperationName => "terms_enum"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases to search. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// When true the provided search string is matched against index terms without case sensitivity. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs index 0c18094311e..51e92fe4cca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs @@ -22,16 +22,74 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propComplete = default; + LocalJsonValue propShards = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComplete.TryReadProperty(ref reader, options, PropComplete, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propTerms.TryReadProperty(ref reader, options, PropTerms, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropTerms, value.Terms, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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.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/_Generated/Api/TextStructure/FindFieldStructureRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureRequest.g.cs index 0e810f8dd67..eef50d3d8a2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureRequest.g.cs @@ -288,6 +288,11 @@ public sealed partial class FindFieldStructureRequestParameters : RequestParamet /// public sealed partial class FindFieldStructureRequest : PlainRequest { + [JsonConstructor] + internal FindFieldStructureRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TextStructureFindFieldStructure; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs index 432ca254f96..205db444ce9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs @@ -22,41 +22,206 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TextStructure; +internal sealed partial class FindFieldStructureResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharset = System.Text.Json.JsonEncodedText.Encode("charset"); + private static readonly System.Text.Json.JsonEncodedText PropEcsCompatibility = System.Text.Json.JsonEncodedText.Encode("ecs_compatibility"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStats = System.Text.Json.JsonEncodedText.Encode("field_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGrokPattern = System.Text.Json.JsonEncodedText.Encode("grok_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropIngestPipeline = System.Text.Json.JsonEncodedText.Encode("ingest_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropJavaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("java_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropJodaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("joda_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropMultilineStartPattern = System.Text.Json.JsonEncodedText.Encode("multiline_start_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropNeedClientTimezone = System.Text.Json.JsonEncodedText.Encode("need_client_timezone"); + private static readonly System.Text.Json.JsonEncodedText PropNumLinesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_lines_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropNumMessagesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_messages_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropSampleStart = System.Text.Json.JsonEncodedText.Encode("sample_start"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override FindFieldStructureResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCharset = default; + LocalJsonValue propEcsCompatibility = default; + LocalJsonValue> propFieldStats = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGrokPattern = default; + LocalJsonValue propIngestPipeline = default; + LocalJsonValue?> propJavaTimestampFormats = default; + LocalJsonValue?> propJodaTimestampFormats = default; + LocalJsonValue propMappings = default; + LocalJsonValue propMultilineStartPattern = default; + LocalJsonValue propNeedClientTimezone = default; + LocalJsonValue propNumLinesAnalyzed = default; + LocalJsonValue propNumMessagesAnalyzed = default; + LocalJsonValue propSampleStart = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharset.TryReadProperty(ref reader, options, PropCharset, null)) + { + continue; + } + + if (propEcsCompatibility.TryReadProperty(ref reader, options, PropEcsCompatibility, null)) + { + continue; + } + + if (propFieldStats.TryReadProperty(ref reader, options, PropFieldStats, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propGrokPattern.TryReadProperty(ref reader, options, PropGrokPattern, null)) + { + continue; + } + + if (propIngestPipeline.TryReadProperty(ref reader, options, PropIngestPipeline, null)) + { + continue; + } + + if (propJavaTimestampFormats.TryReadProperty(ref reader, options, PropJavaTimestampFormats, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propJodaTimestampFormats.TryReadProperty(ref reader, options, PropJodaTimestampFormats, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propMappings.TryReadProperty(ref reader, options, PropMappings, null)) + { + continue; + } + + if (propMultilineStartPattern.TryReadProperty(ref reader, options, PropMultilineStartPattern, null)) + { + continue; + } + + if (propNeedClientTimezone.TryReadProperty(ref reader, options, PropNeedClientTimezone, null)) + { + continue; + } + + if (propNumLinesAnalyzed.TryReadProperty(ref reader, options, PropNumLinesAnalyzed, null)) + { + continue; + } + + if (propNumMessagesAnalyzed.TryReadProperty(ref reader, options, PropNumMessagesAnalyzed, null)) + { + continue; + } + + if (propSampleStart.TryReadProperty(ref reader, options, PropSampleStart, null)) + { + continue; + } + + if (propTimestampField.TryReadProperty(ref reader, options, PropTimestampField, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FindFieldStructureResponse + { + Charset = propCharset.Value +, + EcsCompatibility = propEcsCompatibility.Value +, + FieldStats = propFieldStats.Value +, + Format = propFormat.Value +, + GrokPattern = propGrokPattern.Value +, + IngestPipeline = propIngestPipeline.Value +, + JavaTimestampFormats = propJavaTimestampFormats.Value +, + JodaTimestampFormats = propJodaTimestampFormats.Value +, + Mappings = propMappings.Value +, + MultilineStartPattern = propMultilineStartPattern.Value +, + NeedClientTimezone = propNeedClientTimezone.Value +, + NumLinesAnalyzed = propNumLinesAnalyzed.Value +, + NumMessagesAnalyzed = propNumMessagesAnalyzed.Value +, + SampleStart = propSampleStart.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FindFieldStructureResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharset, value.Charset, null, null); + writer.WriteProperty(options, PropEcsCompatibility, value.EcsCompatibility, null, null); + writer.WriteProperty(options, PropFieldStats, value.FieldStats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropGrokPattern, value.GrokPattern, null, null); + writer.WriteProperty(options, PropIngestPipeline, value.IngestPipeline, null, null); + writer.WriteProperty(options, PropJavaTimestampFormats, value.JavaTimestampFormats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropJodaTimestampFormats, value.JodaTimestampFormats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMappings, value.Mappings, null, null); + writer.WriteProperty(options, PropMultilineStartPattern, value.MultilineStartPattern, null, null); + writer.WriteProperty(options, PropNeedClientTimezone, value.NeedClientTimezone, null, null); + writer.WriteProperty(options, PropNumLinesAnalyzed, value.NumLinesAnalyzed, null, null); + writer.WriteProperty(options, PropNumMessagesAnalyzed, value.NumMessagesAnalyzed, null, null); + writer.WriteProperty(options, PropSampleStart, value.SampleStart, null, null); + writer.WriteProperty(options, PropTimestampField, value.TimestampField, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FindFieldStructureResponseConverter))] public sealed partial class FindFieldStructureResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("charset")] public string Charset { get; init; } - [JsonInclude, JsonPropertyName("ecs_compatibility")] public Elastic.Clients.Elasticsearch.TextStructure.EcsCompatibilityType? EcsCompatibility { get; init; } - [JsonInclude, JsonPropertyName("field_stats")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.TextStructure.FieldStat))] public IReadOnlyDictionary FieldStats { get; init; } - [JsonInclude, JsonPropertyName("format")] public Elastic.Clients.Elasticsearch.TextStructure.FormatType Format { get; init; } - [JsonInclude, JsonPropertyName("grok_pattern")] public string? GrokPattern { get; init; } - [JsonInclude, JsonPropertyName("ingest_pipeline")] public Elastic.Clients.Elasticsearch.Ingest.PipelineConfig IngestPipeline { get; init; } - [JsonInclude, JsonPropertyName("java_timestamp_formats")] public IReadOnlyCollection? JavaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("joda_timestamp_formats")] public IReadOnlyCollection? JodaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } - [JsonInclude, JsonPropertyName("multiline_start_pattern")] public string? MultilineStartPattern { get; init; } - [JsonInclude, JsonPropertyName("need_client_timezone")] public bool NeedClientTimezone { get; init; } - [JsonInclude, JsonPropertyName("num_lines_analyzed")] public int NumLinesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("num_messages_analyzed")] public int NumMessagesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("sample_start")] public string SampleStart { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string? TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureRequest.g.cs index b50c0cabef5..267df8f228c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureRequest.g.cs @@ -293,6 +293,11 @@ public sealed partial class FindMessageStructureRequestParameters : RequestParam /// public sealed partial class FindMessageStructureRequest : PlainRequest { + [JsonConstructor] + internal FindMessageStructureRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TextStructureFindMessageStructure; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs index 922ef596371..feba5d6dcee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs @@ -22,41 +22,206 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TextStructure; +internal sealed partial class FindMessageStructureResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharset = System.Text.Json.JsonEncodedText.Encode("charset"); + private static readonly System.Text.Json.JsonEncodedText PropEcsCompatibility = System.Text.Json.JsonEncodedText.Encode("ecs_compatibility"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStats = System.Text.Json.JsonEncodedText.Encode("field_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGrokPattern = System.Text.Json.JsonEncodedText.Encode("grok_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropIngestPipeline = System.Text.Json.JsonEncodedText.Encode("ingest_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropJavaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("java_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropJodaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("joda_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropMultilineStartPattern = System.Text.Json.JsonEncodedText.Encode("multiline_start_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropNeedClientTimezone = System.Text.Json.JsonEncodedText.Encode("need_client_timezone"); + private static readonly System.Text.Json.JsonEncodedText PropNumLinesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_lines_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropNumMessagesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_messages_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropSampleStart = System.Text.Json.JsonEncodedText.Encode("sample_start"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override FindMessageStructureResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCharset = default; + LocalJsonValue propEcsCompatibility = default; + LocalJsonValue> propFieldStats = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGrokPattern = default; + LocalJsonValue propIngestPipeline = default; + LocalJsonValue?> propJavaTimestampFormats = default; + LocalJsonValue?> propJodaTimestampFormats = default; + LocalJsonValue propMappings = default; + LocalJsonValue propMultilineStartPattern = default; + LocalJsonValue propNeedClientTimezone = default; + LocalJsonValue propNumLinesAnalyzed = default; + LocalJsonValue propNumMessagesAnalyzed = default; + LocalJsonValue propSampleStart = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharset.TryReadProperty(ref reader, options, PropCharset, null)) + { + continue; + } + + if (propEcsCompatibility.TryReadProperty(ref reader, options, PropEcsCompatibility, null)) + { + continue; + } + + if (propFieldStats.TryReadProperty(ref reader, options, PropFieldStats, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propGrokPattern.TryReadProperty(ref reader, options, PropGrokPattern, null)) + { + continue; + } + + if (propIngestPipeline.TryReadProperty(ref reader, options, PropIngestPipeline, null)) + { + continue; + } + + if (propJavaTimestampFormats.TryReadProperty(ref reader, options, PropJavaTimestampFormats, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propJodaTimestampFormats.TryReadProperty(ref reader, options, PropJodaTimestampFormats, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propMappings.TryReadProperty(ref reader, options, PropMappings, null)) + { + continue; + } + + if (propMultilineStartPattern.TryReadProperty(ref reader, options, PropMultilineStartPattern, null)) + { + continue; + } + + if (propNeedClientTimezone.TryReadProperty(ref reader, options, PropNeedClientTimezone, null)) + { + continue; + } + + if (propNumLinesAnalyzed.TryReadProperty(ref reader, options, PropNumLinesAnalyzed, null)) + { + continue; + } + + if (propNumMessagesAnalyzed.TryReadProperty(ref reader, options, PropNumMessagesAnalyzed, null)) + { + continue; + } + + if (propSampleStart.TryReadProperty(ref reader, options, PropSampleStart, null)) + { + continue; + } + + if (propTimestampField.TryReadProperty(ref reader, options, PropTimestampField, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FindMessageStructureResponse + { + Charset = propCharset.Value +, + EcsCompatibility = propEcsCompatibility.Value +, + FieldStats = propFieldStats.Value +, + Format = propFormat.Value +, + GrokPattern = propGrokPattern.Value +, + IngestPipeline = propIngestPipeline.Value +, + JavaTimestampFormats = propJavaTimestampFormats.Value +, + JodaTimestampFormats = propJodaTimestampFormats.Value +, + Mappings = propMappings.Value +, + MultilineStartPattern = propMultilineStartPattern.Value +, + NeedClientTimezone = propNeedClientTimezone.Value +, + NumLinesAnalyzed = propNumLinesAnalyzed.Value +, + NumMessagesAnalyzed = propNumMessagesAnalyzed.Value +, + SampleStart = propSampleStart.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FindMessageStructureResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharset, value.Charset, null, null); + writer.WriteProperty(options, PropEcsCompatibility, value.EcsCompatibility, null, null); + writer.WriteProperty(options, PropFieldStats, value.FieldStats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropGrokPattern, value.GrokPattern, null, null); + writer.WriteProperty(options, PropIngestPipeline, value.IngestPipeline, null, null); + writer.WriteProperty(options, PropJavaTimestampFormats, value.JavaTimestampFormats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropJodaTimestampFormats, value.JodaTimestampFormats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMappings, value.Mappings, null, null); + writer.WriteProperty(options, PropMultilineStartPattern, value.MultilineStartPattern, null, null); + writer.WriteProperty(options, PropNeedClientTimezone, value.NeedClientTimezone, null, null); + writer.WriteProperty(options, PropNumLinesAnalyzed, value.NumLinesAnalyzed, null, null); + writer.WriteProperty(options, PropNumMessagesAnalyzed, value.NumMessagesAnalyzed, null, null); + writer.WriteProperty(options, PropSampleStart, value.SampleStart, null, null); + writer.WriteProperty(options, PropTimestampField, value.TimestampField, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FindMessageStructureResponseConverter))] public sealed partial class FindMessageStructureResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("charset")] public string Charset { get; init; } - [JsonInclude, JsonPropertyName("ecs_compatibility")] public Elastic.Clients.Elasticsearch.TextStructure.EcsCompatibilityType? EcsCompatibility { get; init; } - [JsonInclude, JsonPropertyName("field_stats")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.TextStructure.FieldStat))] public IReadOnlyDictionary FieldStats { get; init; } - [JsonInclude, JsonPropertyName("format")] public Elastic.Clients.Elasticsearch.TextStructure.FormatType Format { get; init; } - [JsonInclude, JsonPropertyName("grok_pattern")] public string? GrokPattern { get; init; } - [JsonInclude, JsonPropertyName("ingest_pipeline")] public Elastic.Clients.Elasticsearch.Ingest.PipelineConfig IngestPipeline { get; init; } - [JsonInclude, JsonPropertyName("java_timestamp_formats")] public IReadOnlyCollection? JavaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("joda_timestamp_formats")] public IReadOnlyCollection? JodaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } - [JsonInclude, JsonPropertyName("multiline_start_pattern")] public string? MultilineStartPattern { get; init; } - [JsonInclude, JsonPropertyName("need_client_timezone")] public bool NeedClientTimezone { get; init; } - [JsonInclude, JsonPropertyName("num_lines_analyzed")] public int NumLinesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("num_messages_analyzed")] public int NumMessagesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("sample_start")] public string SampleStart { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string? TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternRequest.g.cs index 247d72941e7..aab2e55a941 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternRequest.g.cs @@ -49,6 +49,11 @@ public sealed partial class TestGrokPatternRequestParameters : RequestParameters /// public sealed partial class TestGrokPatternRequest : PlainRequest { + [JsonConstructor] + internal TestGrokPatternRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TextStructureTestGrokPattern; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs index 50646b97f83..a812f8b9f01 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propMatches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatches.TryReadProperty(ref reader, options, PropMatches, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs index 4c99c8484f9..b884df0ac56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs @@ -68,6 +68,11 @@ public DeleteTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba { } + [JsonConstructor] + internal DeleteTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementDeleteTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.DELETE; @@ -76,6 +81,14 @@ public DeleteTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba internal override string OperationName => "transform.delete_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// If this value is true, the destination index is deleted together with the transform. If false, the destination diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs index afcb0daed68..83549633bba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTransformResponseConverter))] public sealed partial class DeleteTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/GetTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs index c5d4152ca6b..12160ba114e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs @@ -92,6 +92,7 @@ public sealed partial class GetTransformRequestParameters : RequestParameters /// public sealed partial class GetTransformRequest : PlainRequest { + [JsonConstructor] public GetTransformRequest() { } @@ -108,6 +109,17 @@ public GetTransformRequest(Elastic.Clients.Elasticsearch.Names? transformId) : b internal override string OperationName => "transform.get_transform"; + /// + /// + /// Identifier for the transform. It can be a transform identifier or a + /// wildcard expression. You can get information for all transforms by using + /// _all, by specifying * as the <transform_id>, or by omitting the + /// <transform_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? TransformId { get => P("transform_id"); set => PO("transform_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs index a9ade3c0e06..0f2b19fbadb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTransforms.TryReadProperty(ref reader, options, PropTransforms, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTransforms, value.Transforms, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs index bfd538ede2c..bf3445e43b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs @@ -94,6 +94,11 @@ public GetTransformStatsRequest(Elastic.Clients.Elasticsearch.Names transformId) { } + [JsonConstructor] + internal GetTransformStatsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementGetTransformStats; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; @@ -102,6 +107,17 @@ public GetTransformStatsRequest(Elastic.Clients.Elasticsearch.Names transformId) internal override string OperationName => "transform.get_transform_stats"; + /// + /// + /// Identifier for the transform. It can be a transform identifier or a + /// wildcard expression. You can get information for all transforms by using + /// _all, by specifying * as the <transform_id>, or by omitting the + /// <transform_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs index 463e3808c08..fb3e80af26c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs @@ -22,14 +22,63 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCount = default; + LocalJsonValue> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryReadProperty(ref reader, options, PropCount, null)) + { + continue; + } + + if (propTransforms.TryReadProperty(ref reader, options, PropTransforms, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropTransforms, value.Transforms, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs index c9dd9773b16..d92bcea3e0e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs @@ -54,6 +54,7 @@ public sealed partial class PreviewTransformRequestParameters : RequestParameter /// public sealed partial class PreviewTransformRequest : PlainRequest { + [JsonConstructor] public PreviewTransformRequest() { } @@ -70,6 +71,15 @@ public PreviewTransformRequest(Elastic.Clients.Elasticsearch.Id? transformId) : internal override string OperationName => "transform.preview_transform"; + /// + /// + /// Identifier for the transform to preview. If you specify this path parameter, you cannot provide transform + /// configuration details in the request body. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? TransformId { get => P("transform_id"); set => PO("transform_id", value); } + /// /// /// Period to wait for a response. If no response is received before the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs index 3deeb3c40ce..81393847b15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs @@ -22,14 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propGeneratedDestIndex = default; + LocalJsonValue> propPreview = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propGeneratedDestIndex.TryReadProperty(ref reader, options, PropGeneratedDestIndex, null)) + { + continue; + } + + if (propPreview.TryReadProperty(ref reader, options, PropPreview, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, static TTransform (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker))!)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropPreview, value.Preview, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TTransform v) => w.WriteValueEx(o, v, typeof(SourceMarker)))); + 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.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/_Generated/Api/TransformManagement/PutTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs index 7572393a22f..9aebfe7459f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs @@ -87,6 +87,11 @@ public PutTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : base( { } + [JsonConstructor] + internal PutTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementPutTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.PUT; @@ -95,6 +100,15 @@ public PutTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : base( internal override string OperationName => "transform.put_transform"; + /// + /// + /// Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// When the transform is created, a series of validations occur to ensure its success. For example, there is a diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs index 10f7f7ec4f7..91040ed0e50 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTransformResponseConverter))] public sealed partial class PutTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs index bbe3236f756..f25235510dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs @@ -55,6 +55,11 @@ public ResetTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas { } + [JsonConstructor] + internal ResetTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementResetTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -63,6 +68,15 @@ public ResetTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas internal override string OperationName => "transform.reset_transform"; + /// + /// + /// Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// If this value is true, the transform is reset regardless of its current state. If it's false, the transform diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs index fa10ee989c7..5ec86b3adcc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetTransformResponseConverter))] public sealed partial class ResetTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs index b77da029d31..66cc730b057 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs @@ -58,6 +58,11 @@ public ScheduleNowTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) { } + [JsonConstructor] + internal ScheduleNowTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementScheduleNowTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -66,6 +71,14 @@ public ScheduleNowTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) internal override string OperationName => "transform.schedule_now_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Controls the time to wait for the scheduling to take place diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs index 93f527a6b0c..8ec4a175db2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ScheduleNowTransformResponseConverter))] public sealed partial class ScheduleNowTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/StartTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs index c13718c4ae6..a921ba58124 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs @@ -76,6 +76,11 @@ public StartTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas { } + [JsonConstructor] + internal StartTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementStartTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -84,6 +89,14 @@ public StartTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas internal override string OperationName => "transform.start_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Restricts the set of transformed entities to those changed after this time. Relative times like now-30d are supported. Only applicable for continuous transforms. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs index 04f75c1be41..c19bc83bb23 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTransformResponseConverter))] public sealed partial class StartTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/StopTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs index 83c77465a31..0f4ccd3f586 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs @@ -93,6 +93,11 @@ public StopTransformRequest(Elastic.Clients.Elasticsearch.Name transformId) : ba { } + [JsonConstructor] + internal StopTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementStopTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -101,6 +106,15 @@ public StopTransformRequest(Elastic.Clients.Elasticsearch.Name transformId) : ba internal override string OperationName => "transform.stop_transform"; + /// + /// + /// Identifier for the transform. To stop multiple transforms, use a comma-separated list or a wildcard expression. + /// To stop all transforms, use _all or * as the identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs index 05fbc4e6609..f37cfc52ba5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs @@ -22,10 +22,51 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryReadProperty(ref reader, options, PropAcknowledged, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTransformResponseConverter))] public sealed partial class StopTransformResponse : ElasticsearchResponse { /// @@ -33,6 +74,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/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs index bc612418057..960ad8ec996 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs @@ -69,6 +69,11 @@ public UpdateTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba { } + [JsonConstructor] + internal UpdateTransformRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementUpdateTransform; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -77,6 +82,14 @@ public UpdateTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba internal override string OperationName => "transform.update_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// When true, deferrable validations are not run. This behavior may be diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs index 0dda6e4d96f..39cc99484b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs @@ -22,38 +22,195 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propFrequency = default; + LocalJsonValue propId = default; + LocalJsonValue propLatest = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPivot = default; + LocalJsonValue propRetentionPolicy = default; + LocalJsonValue propSettings = default; + LocalJsonValue propSource = default; + LocalJsonValue propSync = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propCreateTime.TryReadProperty(ref reader, options, PropCreateTime, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propDest.TryReadProperty(ref reader, options, PropDest, null)) + { + continue; + } + + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propLatest.TryReadProperty(ref reader, options, PropLatest, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propPivot.TryReadProperty(ref reader, options, PropPivot, null)) + { + continue; + } + + if (propRetentionPolicy.TryReadProperty(ref reader, options, PropRetentionPolicy, null)) + { + continue; + } + + if (propSettings.TryReadProperty(ref reader, options, PropSettings, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propSync.TryReadProperty(ref reader, options, PropSync, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCreateTime, value.CreateTime, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropDest, value.Dest, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropLatest, value.Latest, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropPivot, value.Pivot, null, null); + writer.WriteProperty(options, PropRetentionPolicy, value.RetentionPolicy, null, null); + writer.WriteProperty(options, PropSettings, value.Settings, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropSync, value.Sync, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateTransformResponseConverter))] public sealed partial class UpdateTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.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.Core.Reindex.Destination Dest { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("latest")] public Elastic.Clients.Elasticsearch.TransformManagement.Latest? Latest { get; init; } - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } - [JsonInclude, JsonPropertyName("pivot")] public Elastic.Clients.Elasticsearch.TransformManagement.Pivot? Pivot { get; init; } - [JsonInclude, JsonPropertyName("retention_policy")] public Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicy? RetentionPolicy { get; init; } - [JsonInclude, JsonPropertyName("settings")] public Elastic.Clients.Elasticsearch.TransformManagement.Settings Settings { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.Core.Reindex.Source Source { get; init; } - [JsonInclude, JsonPropertyName("sync")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/TransformManagement/UpgradeTransformsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsRequest.g.cs index 50bfb0a2008..c4863e40c8c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsRequest.g.cs @@ -70,6 +70,11 @@ public sealed partial class UpgradeTransformsRequestParameters : RequestParamete /// public sealed partial class UpgradeTransformsRequest : PlainRequest { + [JsonConstructor] + internal UpgradeTransformsRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.TransformManagementUpgradeTransforms; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs index d2e39135530..3c5d479d6aa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs @@ -22,10 +22,71 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propNeedsUpdate = default; + LocalJsonValue propNoAction = default; + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNeedsUpdate.TryReadProperty(ref reader, options, PropNeedsUpdate, null)) + { + continue; + } + + if (propNoAction.TryReadProperty(ref reader, options, PropNoAction, null)) + { + continue; + } + + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropNoAction, value.NoAction, null, null); + writer.WriteProperty(options, PropUpdated, value.Updated, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeTransformsResponseConverter))] public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse { /// @@ -33,7 +94,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 +101,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 +108,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/_Generated/Api/UpdateByQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs index 26842bb705f..357c7a88dd9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs @@ -264,6 +264,11 @@ public UpdateByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas { } + [JsonConstructor] + internal UpdateByQueryRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceUpdateByQuery; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -272,6 +277,16 @@ public UpdateByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas internal override string OperationName => "update_by_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs index c08f04aa435..3bdaa0c1d43 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs @@ -22,42 +22,217 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propBatches = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottled = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntil = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propUpdated = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryReadProperty(ref reader, options, PropBatches, null)) + { + continue; + } + + if (propDeleted.TryReadProperty(ref reader, options, PropDeleted, null)) + { + continue; + } + + if (propFailures.TryReadProperty(ref reader, options, PropFailures, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNoops.TryReadProperty(ref reader, options, PropNoops, null)) + { + continue; + } + + if (propRequestsPerSecond.TryReadProperty(ref reader, options, PropRequestsPerSecond, null)) + { + continue; + } + + if (propRetries.TryReadProperty(ref reader, options, PropRetries, null)) + { + continue; + } + + if (propTask.TryReadProperty(ref reader, options, PropTask, null)) + { + continue; + } + + if (propThrottled.TryReadProperty(ref reader, options, PropThrottled, null)) + { + continue; + } + + if (propThrottledMillis.TryReadProperty(ref reader, options, PropThrottledMillis, null)) + { + continue; + } + + if (propThrottledUntil.TryReadProperty(ref reader, options, PropThrottledUntil, null)) + { + continue; + } + + if (propThrottledUntilMillis.TryReadProperty(ref reader, options, PropThrottledUntilMillis, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (propUpdated.TryReadProperty(ref reader, options, PropUpdated, null)) + { + continue; + } + + if (propVersionConflicts.TryReadProperty(ref reader, options, PropVersionConflicts, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDeleted, value.Deleted, null, null); + writer.WriteProperty(options, PropFailures, value.Failures, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNoops, value.Noops, null, null); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond, null, null); + writer.WriteProperty(options, PropRetries, value.Retries, null, null); + writer.WriteProperty(options, PropTask, value.Task, null, null); + writer.WriteProperty(options, PropThrottled, value.Throttled, null, null); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis, null, null); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil, null, null); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteProperty(options, PropUpdated, value.Updated, null, null); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts, null, null); + 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.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs index 6ee3ca87ed4..072862aa0af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs @@ -55,6 +55,11 @@ public UpdateByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : { } + [JsonConstructor] + internal UpdateByQueryRethrottleRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceUpdateByQueryRethrottle; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -63,6 +68,14 @@ public UpdateByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : internal override string OperationName => "update_by_query_rethrottle"; + /// + /// + /// The ID for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs index ed940ed3d73..5054907f969 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs @@ -22,12 +22,52 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + 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/_Generated/Api/UpdateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs index 2b7fb9ce352..5e2f74754d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs @@ -116,18 +116,139 @@ public sealed partial class UpdateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDetectNoop = default; + LocalJsonValue propDoc = default; + LocalJsonValue propDocAsUpsert = default; + LocalJsonValue propScript = default; + LocalJsonValue propScriptedUpsert = default; + LocalJsonValue propSource = default; + LocalJsonValue propUpsert = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetectNoop.TryReadProperty(ref reader, options, PropDetectNoop, null)) + { + continue; + } + + if (propDoc.TryReadProperty(ref reader, options, PropDoc, static TPartialDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propDocAsUpsert.TryReadProperty(ref reader, options, PropDocAsUpsert, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propScriptedUpsert.TryReadProperty(ref reader, options, PropScriptedUpsert, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propUpsert.TryReadProperty(ref reader, options, PropUpsert, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDoc, value.Doc, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TPartialDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropDocAsUpsert, value.DocAsUpsert, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropScriptedUpsert, value.ScriptedUpsert, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropUpsert, value.Upsert, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, 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.IndexName index, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", index).Required("id", id)) { } + [JsonConstructor] + internal UpdateRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceUpdate; protected override HttpMethod StaticHttpMethod => HttpMethod.POST; @@ -136,12 +257,25 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "update"; + /// + /// + /// Document ID + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// The name of the index + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// 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 +283,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// 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 +290,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// The script language. /// /// - [JsonIgnore] public string? Lang { get => Q("lang"); set => Q("lang", value); } /// @@ -167,7 +299,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// visible to search, if 'false' do nothing with refreshes. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } /// @@ -175,7 +306,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// If true, the destination must be an index alias. /// /// - [JsonIgnore] public bool? RequireAlias { get => Q("require_alias"); set => Q("require_alias", value); } /// @@ -183,7 +313,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// 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 +320,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -199,7 +327,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specify the source fields you want to exclude. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -207,7 +334,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specify the source fields you want to retrieve. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -217,7 +343,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// The actual wait time could be longer, particularly when multiple waits occur. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -227,7 +352,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// (number_of_replicas+1). Defaults to 1 meaning the primary shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } /// @@ -236,7 +360,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// to 'noop' if no change to the document occurred. /// /// - [JsonInclude, JsonPropertyName("detect_noop")] public bool? DetectNoop { get; set; } /// @@ -244,8 +367,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// A partial update to an existing document. /// /// - [JsonInclude, JsonPropertyName("doc")] - [SourceConverter] public TPartialDocument? Doc { get; set; } /// @@ -253,7 +374,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// 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 +381,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Script to execute to update the document. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -269,7 +388,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Set to true to execute the script whether or not the document exists. /// /// - [JsonInclude, JsonPropertyName("scripted_upsert")] public bool? ScriptedUpsert { get; set; } /// @@ -278,7 +396,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// list of the fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -287,8 +404,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// 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/_Generated/Api/UpdateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs index fb1f7195afe..2db61bfc25a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs @@ -22,28 +22,157 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue?> propGet = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, null)) + { + continue; + } + + if (propGet.TryReadProperty(ref reader, options, PropGet, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropGet, value.Get, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropResult, value.Result, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.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.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Xpack/XpackInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoRequest.g.cs index 42b67ad0cb0..acbf6a9284b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoRequest.g.cs @@ -72,6 +72,11 @@ public sealed partial class XpackInfoRequestParameters : RequestParameters /// public sealed partial class XpackInfoRequest : PlainRequest { + [JsonConstructor] + internal XpackInfoRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.XpackInfo; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs index 6b636e1191f..859b92e94dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs @@ -22,18 +22,85 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBuild = default; + LocalJsonValue propFeatures = default; + LocalJsonValue propLicense = default; + LocalJsonValue propTagline = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuild.TryReadProperty(ref reader, options, PropBuild, null)) + { + continue; + } + + if (propFeatures.TryReadProperty(ref reader, options, PropFeatures, null)) + { + continue; + } + + if (propLicense.TryReadProperty(ref reader, options, PropLicense, null)) + { + continue; + } + + if (propTagline.TryReadProperty(ref reader, options, PropTagline, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFeatures, value.Features, null, null); + writer.WriteProperty(options, PropLicense, value.License, null, null); + writer.WriteProperty(options, PropTagline, value.Tagline, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackInfoResponseConverter))] public sealed partial class XpackInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("build")] public Elastic.Clients.Elasticsearch.Xpack.BuildInformation Build { get; init; } - [JsonInclude, JsonPropertyName("features")] public Elastic.Clients.Elasticsearch.Xpack.Features Features { get; init; } - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.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/_Generated/Api/Xpack/XpackUsageRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageRequest.g.cs index f166a00e6dc..5e0a082096c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageRequest.g.cs @@ -49,6 +49,11 @@ public sealed partial class XpackUsageRequestParameters : RequestParameters /// public sealed partial class XpackUsageRequest : PlainRequest { + [JsonConstructor] + internal XpackUsageRequest() + { + } + internal override ApiUrls ApiUrls => ApiUrlLookup.XpackUsage; protected override HttpMethod StaticHttpMethod => HttpMethod.GET; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs index 347789ed115..9d1fa8962b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs @@ -22,68 +22,360 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAggregateMetric = default; + LocalJsonValue propAnalytics = default; + LocalJsonValue propArchive = default; + LocalJsonValue propCcr = default; + LocalJsonValue propDataFrame = default; + LocalJsonValue propDataScience = default; + LocalJsonValue propDataStreams = default; + LocalJsonValue propDataTiers = default; + LocalJsonValue propEnrich = default; + LocalJsonValue propEql = default; + LocalJsonValue propFlattened = default; + LocalJsonValue propFrozenIndices = default; + LocalJsonValue propGraph = default; + LocalJsonValue propHealthApi = default; + LocalJsonValue propIlm = default; + LocalJsonValue propLogstash = default; + LocalJsonValue propMl = default; + LocalJsonValue propMonitoring = default; + LocalJsonValue propRollup = default; + LocalJsonValue propRuntimeFields = default; + LocalJsonValue propSearchableSnapshots = default; + LocalJsonValue propSecurity = default; + LocalJsonValue propSlm = default; + LocalJsonValue propSpatial = default; + LocalJsonValue propSql = default; + LocalJsonValue propTransform = default; + LocalJsonValue propVectors = default; + LocalJsonValue propVotingOnly = default; + LocalJsonValue propWatcher = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregateMetric.TryReadProperty(ref reader, options, PropAggregateMetric, null)) + { + continue; + } + + if (propAnalytics.TryReadProperty(ref reader, options, PropAnalytics, null)) + { + continue; + } + + if (propArchive.TryReadProperty(ref reader, options, PropArchive, null)) + { + continue; + } + + if (propCcr.TryReadProperty(ref reader, options, PropCcr, null)) + { + continue; + } + + if (propDataFrame.TryReadProperty(ref reader, options, PropDataFrame, null)) + { + continue; + } + + if (propDataScience.TryReadProperty(ref reader, options, PropDataScience, null)) + { + continue; + } + + if (propDataStreams.TryReadProperty(ref reader, options, PropDataStreams, null)) + { + continue; + } + + if (propDataTiers.TryReadProperty(ref reader, options, PropDataTiers, null)) + { + continue; + } + + if (propEnrich.TryReadProperty(ref reader, options, PropEnrich, null)) + { + continue; + } + + if (propEql.TryReadProperty(ref reader, options, PropEql, null)) + { + continue; + } + + if (propFlattened.TryReadProperty(ref reader, options, PropFlattened, null)) + { + continue; + } + + if (propFrozenIndices.TryReadProperty(ref reader, options, PropFrozenIndices, null)) + { + continue; + } + + if (propGraph.TryReadProperty(ref reader, options, PropGraph, null)) + { + continue; + } + + if (propHealthApi.TryReadProperty(ref reader, options, PropHealthApi, null)) + { + continue; + } + + if (propIlm.TryReadProperty(ref reader, options, PropIlm, null)) + { + continue; + } + + if (propLogstash.TryReadProperty(ref reader, options, PropLogstash, null)) + { + continue; + } + + if (propMl.TryReadProperty(ref reader, options, PropMl, null)) + { + continue; + } + + if (propMonitoring.TryReadProperty(ref reader, options, PropMonitoring, null)) + { + continue; + } + + if (propRollup.TryReadProperty(ref reader, options, PropRollup, null)) + { + continue; + } + + if (propRuntimeFields.TryReadProperty(ref reader, options, PropRuntimeFields, null)) + { + continue; + } + + if (propSearchableSnapshots.TryReadProperty(ref reader, options, PropSearchableSnapshots, null)) + { + continue; + } + + if (propSecurity.TryReadProperty(ref reader, options, PropSecurity, null)) + { + continue; + } + + if (propSlm.TryReadProperty(ref reader, options, PropSlm, null)) + { + continue; + } + + if (propSpatial.TryReadProperty(ref reader, options, PropSpatial, null)) + { + continue; + } + + if (propSql.TryReadProperty(ref reader, options, PropSql, null)) + { + continue; + } + + if (propTransform.TryReadProperty(ref reader, options, PropTransform, null)) + { + continue; + } + + if (propVectors.TryReadProperty(ref reader, options, PropVectors, null)) + { + continue; + } + + if (propVotingOnly.TryReadProperty(ref reader, options, PropVotingOnly, null)) + { + continue; + } + + if (propWatcher.TryReadProperty(ref reader, options, PropWatcher, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAnalytics, value.Analytics, null, null); + writer.WriteProperty(options, PropArchive, value.Archive, null, null); + writer.WriteProperty(options, PropCcr, value.Ccr, null, null); + writer.WriteProperty(options, PropDataFrame, value.DataFrame, null, null); + writer.WriteProperty(options, PropDataScience, value.DataScience, null, null); + writer.WriteProperty(options, PropDataStreams, value.DataStreams, null, null); + writer.WriteProperty(options, PropDataTiers, value.DataTiers, null, null); + writer.WriteProperty(options, PropEnrich, value.Enrich, null, null); + writer.WriteProperty(options, PropEql, value.Eql, null, null); + writer.WriteProperty(options, PropFlattened, value.Flattened, null, null); + writer.WriteProperty(options, PropFrozenIndices, value.FrozenIndices, null, null); + writer.WriteProperty(options, PropGraph, value.Graph, null, null); + writer.WriteProperty(options, PropHealthApi, value.HealthApi, null, null); + writer.WriteProperty(options, PropIlm, value.Ilm, null, null); + writer.WriteProperty(options, PropLogstash, value.Logstash, null, null); + writer.WriteProperty(options, PropMl, value.Ml, null, null); + writer.WriteProperty(options, PropMonitoring, value.Monitoring, null, null); + writer.WriteProperty(options, PropRollup, value.Rollup, null, null); + writer.WriteProperty(options, PropRuntimeFields, value.RuntimeFields, null, null); + writer.WriteProperty(options, PropSearchableSnapshots, value.SearchableSnapshots, null, null); + writer.WriteProperty(options, PropSecurity, value.Security, null, null); + writer.WriteProperty(options, PropSlm, value.Slm, null, null); + writer.WriteProperty(options, PropSpatial, value.Spatial, null, null); + writer.WriteProperty(options, PropSql, value.Sql, null, null); + writer.WriteProperty(options, PropTransform, value.Transform, null, null); + writer.WriteProperty(options, PropVectors, value.Vectors, null, null); + writer.WriteProperty(options, PropVotingOnly, value.VotingOnly, null, null); + writer.WriteProperty(options, PropWatcher, value.Watcher, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackUsageResponseConverter))] public sealed partial class XpackUsageResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregate_metric")] public Elastic.Clients.Elasticsearch.Xpack.Base AggregateMetric { get; init; } - [JsonInclude, JsonPropertyName("analytics")] public Elastic.Clients.Elasticsearch.Xpack.Analytics Analytics { get; init; } - [JsonInclude, JsonPropertyName("archive")] public Elastic.Clients.Elasticsearch.Xpack.Archive Archive { get; init; } - [JsonInclude, JsonPropertyName("ccr")] public Elastic.Clients.Elasticsearch.Xpack.Ccr Ccr { get; init; } - [JsonInclude, JsonPropertyName("data_frame")] public Elastic.Clients.Elasticsearch.Xpack.Base? DataFrame { get; init; } - [JsonInclude, JsonPropertyName("data_science")] public Elastic.Clients.Elasticsearch.Xpack.Base? DataScience { get; init; } - [JsonInclude, JsonPropertyName("data_streams")] public Elastic.Clients.Elasticsearch.Xpack.DataStreams? DataStreams { get; init; } - [JsonInclude, JsonPropertyName("data_tiers")] public Elastic.Clients.Elasticsearch.Xpack.DataTiers DataTiers { get; init; } - [JsonInclude, JsonPropertyName("enrich")] public Elastic.Clients.Elasticsearch.Xpack.Base? Enrich { get; init; } - [JsonInclude, JsonPropertyName("eql")] public Elastic.Clients.Elasticsearch.Xpack.Eql Eql { get; init; } - [JsonInclude, JsonPropertyName("flattened")] public Elastic.Clients.Elasticsearch.Xpack.Flattened? Flattened { get; init; } - [JsonInclude, JsonPropertyName("frozen_indices")] public Elastic.Clients.Elasticsearch.Xpack.FrozenIndices FrozenIndices { get; init; } - [JsonInclude, JsonPropertyName("graph")] public Elastic.Clients.Elasticsearch.Xpack.Base Graph { get; init; } - [JsonInclude, JsonPropertyName("health_api")] public Elastic.Clients.Elasticsearch.Xpack.HealthStatistics? HealthApi { get; init; } - [JsonInclude, JsonPropertyName("ilm")] public Elastic.Clients.Elasticsearch.Xpack.Ilm Ilm { get; init; } - [JsonInclude, JsonPropertyName("logstash")] public Elastic.Clients.Elasticsearch.Xpack.Base Logstash { get; init; } - [JsonInclude, JsonPropertyName("ml")] public Elastic.Clients.Elasticsearch.Xpack.MachineLearning Ml { get; init; } - [JsonInclude, JsonPropertyName("monitoring")] public Elastic.Clients.Elasticsearch.Xpack.Monitoring Monitoring { get; init; } - [JsonInclude, JsonPropertyName("rollup")] public Elastic.Clients.Elasticsearch.Xpack.Base Rollup { get; init; } - [JsonInclude, JsonPropertyName("runtime_fields")] public Elastic.Clients.Elasticsearch.Xpack.RuntimeFieldTypes? RuntimeFields { get; init; } - [JsonInclude, JsonPropertyName("searchable_snapshots")] public Elastic.Clients.Elasticsearch.Xpack.SearchableSnapshots SearchableSnapshots { get; init; } - [JsonInclude, JsonPropertyName("security")] public Elastic.Clients.Elasticsearch.Xpack.Security Security { get; init; } - [JsonInclude, JsonPropertyName("slm")] public Elastic.Clients.Elasticsearch.Xpack.Slm Slm { get; init; } - [JsonInclude, JsonPropertyName("spatial")] public Elastic.Clients.Elasticsearch.Xpack.Base Spatial { get; init; } - [JsonInclude, JsonPropertyName("sql")] public Elastic.Clients.Elasticsearch.Xpack.Sql Sql { get; init; } - [JsonInclude, JsonPropertyName("transform")] public Elastic.Clients.Elasticsearch.Xpack.Base Transform { get; init; } - [JsonInclude, JsonPropertyName("vectors")] public Elastic.Clients.Elasticsearch.Xpack.Vector? Vectors { get; init; } - [JsonInclude, JsonPropertyName("voting_only")] public Elastic.Clients.Elasticsearch.Xpack.Base VotingOnly { get; init; } - [JsonInclude, JsonPropertyName("watcher")] public Elastic.Clients.Elasticsearch.Xpack.Watcher Watcher { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs index 5b0e0007e35..a2965704b6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs index f238c0e248c..43d7e4d17a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new AdjacencyMatrixBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AdjacencyMatrixBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs index 6198ae808d5..129b497b167 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs @@ -33,6 +33,7 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; public partial interface IAggregate { + public string? Type { get; } } [JsonConverter(typeof(AggregateDictionaryConverter))] @@ -115,530 +116,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) + var key = reader.ReadPropertyName(options, null); + 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, null), + "auto_date_histogram" => reader.ReadValue(options, null), + "avg" => reader.ReadValue(options, null), + "boxplot" => reader.ReadValue(options, null), + "bucket_metric_value" => reader.ReadValue(options, null), + "cardinality" => reader.ReadValue(options, null), + "children" => reader.ReadValue(options, null), + "composite" => reader.ReadValue(options, null), + "simple_long_value" => reader.ReadValue(options, null), + "date_histogram" => reader.ReadValue(options, null), + "date_range" => reader.ReadValue(options, null), + "derivative" => reader.ReadValue(options, null), + "dterms" => reader.ReadValue(options, null), + "extended_stats" => reader.ReadValue(options, null), + "extended_stats_bucket" => reader.ReadValue(options, null), + "filter" => reader.ReadValue(options, null), + "filters" => reader.ReadValue(options, null), + "frequent_item_sets" => reader.ReadValue(options, null), + "geo_bounds" => reader.ReadValue(options, null), + "geo_centroid" => reader.ReadValue(options, null), + "geo_distance" => reader.ReadValue(options, null), + "geohash_grid" => reader.ReadValue(options, null), + "geohex_grid" => reader.ReadValue(options, null), + "geo_line" => reader.ReadValue(options, null), + "geotile_grid" => reader.ReadValue(options, null), + "global" => reader.ReadValue(options, null), + "hdr_percentile_ranks" => reader.ReadValue(options, null), + "hdr_percentiles" => reader.ReadValue(options, null), + "histogram" => reader.ReadValue(options, null), + "inference" => reader.ReadValue(options, null), + "ip_prefix" => reader.ReadValue(options, null), + "ip_range" => reader.ReadValue(options, null), + "lrareterms" => reader.ReadValue(options, null), + "lterms" => reader.ReadValue(options, null), + "matrix_stats" => reader.ReadValue(options, null), + "max" => reader.ReadValue(options, null), + "median_absolute_deviation" => reader.ReadValue(options, null), + "min" => reader.ReadValue(options, null), + "missing" => reader.ReadValue(options, null), + "multi_terms" => reader.ReadValue(options, null), + "nested" => reader.ReadValue(options, null), + "parent" => reader.ReadValue(options, null), + "percentiles_bucket" => reader.ReadValue(options, null), + "range" => reader.ReadValue(options, null), + "rate" => reader.ReadValue(options, null), + "reverse_nested" => reader.ReadValue(options, null), + "sampler" => reader.ReadValue(options, null), + "scripted_metric" => reader.ReadValue(options, null), + "siglterms" => reader.ReadValue(options, null), + "sigsterms" => reader.ReadValue(options, null), + "simple_value" => reader.ReadValue(options, null), + "stats" => reader.ReadValue(options, null), + "stats_bucket" => reader.ReadValue(options, null), + "srareterms" => reader.ReadValue(options, null), + "string_stats" => reader.ReadValue(options, null), + "sterms" => reader.ReadValue(options, null), + "sum" => reader.ReadValue(options, null), + "tdigest_percentile_ranks" => reader.ReadValue(options, null), + "tdigest_percentiles" => reader.ReadValue(options, null), + "time_series" => reader.ReadValue(options, null), + "top_hits" => reader.ReadValue(options, null), + "top_metrics" => reader.ReadValue(options, null), + "t_test" => reader.ReadValue(options, null), + "umrareterms" => reader.ReadValue(options, null), + "unmapped_sampler" => reader.ReadValue(options, null), + "umsigterms" => reader.ReadValue(options, null), + "umterms" => reader.ReadValue(options, null), + "value_count" => reader.ReadValue(options, null), + "variable_width_histogram" => reader.ReadValue(options, null), + "weighted_avg" => reader.ReadValue(options, null), + _ => 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.Aggregations.AdjacencyMatrixAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.AverageAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.BucketMetricValueAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DoubleTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FilterAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HdrPercentileRanksAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HdrPercentilesAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.LongRareTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.LongTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MaxAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MinAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MissingAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.NestedAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ParentAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.RangeAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.RateAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SignificantLongTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SignificantStringTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SimpleValueAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StatsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringRareTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SumAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentileRanksAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentilesAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TTestAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedRareTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedSamplerAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedSignificantTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedTermsAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregate v: + writer.WriteProperty(options, key, v, null, null); + break; + case Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate v: + writer.WriteProperty(options, key, v, null, null); + 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/_Generated/Types/Aggregations/Aggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs index 3ce7c7ac1d7..2e32d9f57a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs @@ -39,12 +39,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.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => new Aggregation("adjacency_matrix", adjacencyMatrixAggregation); public static Aggregation AutoDateHistogram(Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => new Aggregation("auto_date_histogram", autoDateHistogramAggregation); @@ -148,847 +152,987 @@ 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 VariantBucketCorrelation = System.Text.Json.JsonEncodedText.Encode("bucket_correlation"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketCountKsTest = System.Text.Json.JsonEncodedText.Encode("bucket_count_ks_test"); + 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 VariantCategorizeText = System.Text.Json.JsonEncodedText.Encode("categorize_text"); + 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 VariantRandomSampler = System.Text.Json.JsonEncodedText.Encode("random_sampler"); + 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 VariantTimeSeries = System.Text.Json.JsonEncodedText.Encode("time_series"); + 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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue?> 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) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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 == "aggregations") + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - aggregationsValue = JsonSerializer.Deserialize?>(ref reader, options); continue; } - if (propertyName == "meta") + if (reader.ValueTextEquals(VariantAdjacencyMatrix)) { - metaValue = JsonSerializer.Deserialize?>(ref reader, options); + variantType = VariantAdjacencyMatrix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "adjacency_matrix") + if (reader.ValueTextEquals(VariantAutoDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAutoDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "auto_date_histogram") + if (reader.ValueTextEquals(VariantAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvg.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "avg") + if (reader.ValueTextEquals(VariantAvgBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvgBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "avg_bucket") + if (reader.ValueTextEquals(VariantBoxplot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoxplot.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "boxplot") + if (reader.ValueTextEquals(VariantBucketCorrelation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketCorrelation.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bucket_correlation") + if (reader.ValueTextEquals(VariantBucketCountKsTest)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketCountKsTest.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bucket_count_ks_test") + if (reader.ValueTextEquals(VariantBucketScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketScript.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bucket_script") + if (reader.ValueTextEquals(VariantBucketSelector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSelector.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bucket_selector") + if (reader.ValueTextEquals(VariantBucketSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSort.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bucket_sort") + if (reader.ValueTextEquals(VariantCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "cardinality") + if (reader.ValueTextEquals(VariantCategorizeText)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCategorizeText.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "categorize_text") + if (reader.ValueTextEquals(VariantChildren)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantChildren.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "children") + if (reader.ValueTextEquals(VariantComposite)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantComposite.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "composite") + if (reader.ValueTextEquals(VariantCumulativeCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "cumulative_cardinality") + if (reader.ValueTextEquals(VariantCumulativeSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeSum.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "cumulative_sum") + if (reader.ValueTextEquals(VariantDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "date_histogram") + if (reader.ValueTextEquals(VariantDateRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateRange.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "date_range") + if (reader.ValueTextEquals(VariantDerivative)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDerivative.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "derivative") + if (reader.ValueTextEquals(VariantDiversifiedSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDiversifiedSampler.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "diversified_sampler") + if (reader.ValueTextEquals(VariantExtendedStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStats.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "extended_stats") + if (reader.ValueTextEquals(VariantExtendedStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "extended_stats_bucket") + if (reader.ValueTextEquals(VariantFilter)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilter.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "filter") + if (reader.ValueTextEquals(VariantFilters)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilters.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "filters") + if (reader.ValueTextEquals(VariantFrequentItemSets)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequentItemSets.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "frequent_item_sets") + if (reader.ValueTextEquals(VariantGeoBounds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBounds.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_bounds") + if (reader.ValueTextEquals(VariantGeoCentroid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoCentroid.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_centroid") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeohashGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohashGrid.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geohash_grid") + if (reader.ValueTextEquals(VariantGeohexGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohexGrid.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geohex_grid") + if (reader.ValueTextEquals(VariantGeoLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoLine.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_line") + if (reader.ValueTextEquals(VariantGeotileGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeotileGrid.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geotile_grid") + if (reader.ValueTextEquals(VariantGlobal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGlobal.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "global") + if (reader.ValueTextEquals(VariantHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "histogram") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantIpPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ip_prefix") + if (reader.ValueTextEquals(VariantIpRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpRange.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ip_range") + if (reader.ValueTextEquals(VariantLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLine.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "line") + if (reader.ValueTextEquals(VariantMatrixStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatrixStats.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "matrix_stats") + if (reader.ValueTextEquals(VariantMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMax.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "max") + if (reader.ValueTextEquals(VariantMaxBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "max_bucket") + if (reader.ValueTextEquals(VariantMedianAbsoluteDeviation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMedianAbsoluteDeviation.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "median_absolute_deviation") + if (reader.ValueTextEquals(VariantMin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMin.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "min") + if (reader.ValueTextEquals(VariantMinBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMinBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "min_bucket") + if (reader.ValueTextEquals(VariantMissing)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMissing.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "missing") + if (reader.ValueTextEquals(VariantMovingFn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingFn.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "moving_fn") + if (reader.ValueTextEquals(VariantMovingPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "moving_percentiles") + if (reader.ValueTextEquals(VariantMultiTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiTerms.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "multi_terms") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantNormalize)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNormalize.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "normalize") + if (reader.ValueTextEquals(VariantParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParent.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "parent") + if (reader.ValueTextEquals(VariantPercentileRanks)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentileRanks.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "percentile_ranks") + if (reader.ValueTextEquals(VariantPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "percentiles") + if (reader.ValueTextEquals(VariantPercentilesBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentilesBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "percentiles_bucket") + if (reader.ValueTextEquals(VariantRandomSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRandomSampler.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "random_sampler") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRareTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRareTerms.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rare_terms") + if (reader.ValueTextEquals(VariantRate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRate.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rate") + if (reader.ValueTextEquals(VariantReverseNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReverseNested.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "reverse_nested") + if (reader.ValueTextEquals(VariantSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSampler.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "sampler") + if (reader.ValueTextEquals(VariantScriptedMetric)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptedMetric.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "scripted_metric") + if (reader.ValueTextEquals(VariantSerialDiff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSerialDiff.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "serial_diff") + if (reader.ValueTextEquals(VariantSignificantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "significant_terms") + if (reader.ValueTextEquals(VariantSignificantText)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantText.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "significant_text") + if (reader.ValueTextEquals(VariantStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStats.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "stats") + if (reader.ValueTextEquals(VariantStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "stats_bucket") + if (reader.ValueTextEquals(VariantStringStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStringStats.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "string_stats") + if (reader.ValueTextEquals(VariantSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSum.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "sum") + if (reader.ValueTextEquals(VariantSumBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSumBucket.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "sum_bucket") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTimeSeries)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTimeSeries.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "time_series") + if (reader.ValueTextEquals(VariantTopHits)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopHits.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "top_hits") + if (reader.ValueTextEquals(VariantTopMetrics)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopMetrics.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "top_metrics") + if (reader.ValueTextEquals(VariantTTest)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTTest.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "t_test") + if (reader.ValueTextEquals(VariantValueCount)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantValueCount.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "value_count") + if (reader.ValueTextEquals(VariantVariableWidthHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantVariableWidthHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "variable_width_histogram") + if (reader.ValueTextEquals(VariantWeightedAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeightedAvg.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "weighted_avg") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.Aggregations.AdjacencyMatrixAggregation)value.Variant, options); - break; - case "auto_date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation)value.Variant, options); - break; - case "avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AverageAggregation)value.Variant, options); - break; - case "avg_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AverageBucketAggregation)value.Variant, options); - break; - case "boxplot": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregation)value.Variant, options); - break; - case "bucket_correlation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationAggregation)value.Variant, options); - break; - case "bucket_count_ks_test": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketKsAggregation)value.Variant, options); - break; - case "bucket_script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketScriptAggregation)value.Variant, options); - break; - case "bucket_selector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketSelectorAggregation)value.Variant, options); - break; - case "bucket_sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketSortAggregation)value.Variant, options); - break; - case "cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregation)value.Variant, options); - break; - case "categorize_text": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CategorizeTextAggregation)value.Variant, options); - break; - case "children": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregation)value.Variant, options); - break; - case "composite": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregation)value.Variant, options); - break; - case "cumulative_cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregation)value.Variant, options); - break; - case "cumulative_sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeSumAggregation)value.Variant, options); - break; - case "date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregation)value.Variant, options); - break; - case "date_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation)value.Variant, options); - break; - case "derivative": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregation)value.Variant, options); - break; - case "diversified_sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DiversifiedSamplerAggregation)value.Variant, options); - break; - case "extended_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregation)value.Variant, options); - break; - case "extended_stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregation)value.Variant, options); - break; - case "filter": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Query)value.Variant, options); - break; - case "filters": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregation)value.Variant, options); - break; - case "frequent_item_sets": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregation)value.Variant, options); - break; - case "geo_bounds": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregation)value.Variant, options); - break; - case "geo_centroid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregation)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregation)value.Variant, options); - break; - case "geohash_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregation)value.Variant, options); - break; - case "geohex_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregation)value.Variant, options); - break; - case "geo_line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "geotile_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregation)value.Variant, options); - break; - case "global": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregation)value.Variant, options); - break; - case "histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregation)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregation)value.Variant, options); - break; - case "ip_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregation)value.Variant, options); - break; - case "ip_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregation)value.Variant, options); - break; - case "line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "matrix_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation)value.Variant, options); - break; - case "max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MaxAggregation)value.Variant, options); - break; - case "max_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MaxBucketAggregation)value.Variant, options); - break; - case "median_absolute_deviation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregation)value.Variant, options); - break; - case "min": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MinAggregation)value.Variant, options); - break; - case "min_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MinBucketAggregation)value.Variant, options); - break; - case "missing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MissingAggregation)value.Variant, options); - break; - case "moving_fn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MovingFunctionAggregation)value.Variant, options); - break; - case "moving_percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MovingPercentilesAggregation)value.Variant, options); - break; - case "multi_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregation)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.NestedAggregation)value.Variant, options); - break; - case "normalize": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.NormalizeAggregation)value.Variant, options); - break; - case "parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ParentAggregation)value.Variant, options); - break; - case "percentile_ranks": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentileRanksAggregation)value.Variant, options); - break; - case "percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesAggregation)value.Variant, options); - break; - case "percentiles_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregation)value.Variant, options); - break; - case "random_sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RandomSamplerAggregation)value.Variant, options); - break; - case "range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RangeAggregation)value.Variant, options); - break; - case "rare_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RareTermsAggregation)value.Variant, options); - break; - case "rate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RateAggregation)value.Variant, options); - break; - case "reverse_nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregation)value.Variant, options); - break; - case "sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregation)value.Variant, options); - break; - case "scripted_metric": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregation)value.Variant, options); - break; - case "serial_diff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SerialDifferencingAggregation)value.Variant, options); - break; - case "significant_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTermsAggregation)value.Variant, options); - break; - case "significant_text": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTextAggregation)value.Variant, options); - break; - case "stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StatsAggregation)value.Variant, options); - break; - case "stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregation)value.Variant, options); - break; - case "string_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregation)value.Variant, options); - break; - case "sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SumAggregation)value.Variant, options); - break; - case "sum_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SumBucketAggregation)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TermsAggregation)value.Variant, options); - break; - case "time_series": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregation)value.Variant, options); - break; - case "top_hits": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregation)value.Variant, options); - break; - case "top_metrics": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregation)value.Variant, options); - break; - case "t_test": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TTestAggregation)value.Variant, options); - break; - case "value_count": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregation)value.Variant, options); - break; - case "variable_width_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregation)value.Variant, options); - break; - case "weighted_avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation)value.Variant, options); - break; - } + case "": + break; + case "adjacency_matrix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AdjacencyMatrixAggregation?)value.Variant, null, null); + break; + case "auto_date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation?)value.Variant, null, null); + break; + case "avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AverageAggregation?)value.Variant, null, null); + break; + case "avg_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AverageBucketAggregation?)value.Variant, null, null); + break; + case "boxplot": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregation?)value.Variant, null, null); + break; + case "bucket_correlation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationAggregation?)value.Variant, null, null); + break; + case "bucket_count_ks_test": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketKsAggregation?)value.Variant, null, null); + break; + case "bucket_script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketScriptAggregation?)value.Variant, null, null); + break; + case "bucket_selector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketSelectorAggregation?)value.Variant, null, null); + break; + case "bucket_sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketSortAggregation?)value.Variant, null, null); + break; + case "cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregation?)value.Variant, null, null); + break; + case "categorize_text": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CategorizeTextAggregation?)value.Variant, null, null); + break; + case "children": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregation?)value.Variant, null, null); + break; + case "composite": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregation?)value.Variant, null, null); + break; + case "cumulative_cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregation?)value.Variant, null, null); + break; + case "cumulative_sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeSumAggregation?)value.Variant, null, null); + break; + case "date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregation?)value.Variant, null, null); + break; + case "date_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation?)value.Variant, null, null); + break; + case "derivative": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregation?)value.Variant, null, null); + break; + case "diversified_sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DiversifiedSamplerAggregation?)value.Variant, null, null); + break; + case "extended_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregation?)value.Variant, null, null); + break; + case "extended_stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregation?)value.Variant, null, null); + break; + case "filter": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Query?)value.Variant, null, null); + break; + case "filters": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregation?)value.Variant, null, null); + break; + case "frequent_item_sets": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregation?)value.Variant, null, null); + break; + case "geo_bounds": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregation?)value.Variant, null, null); + break; + case "geo_centroid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregation?)value.Variant, null, null); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregation?)value.Variant, null, null); + break; + case "geohash_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregation?)value.Variant, null, null); + break; + case "geohex_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregation?)value.Variant, null, null); + break; + case "geo_line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation?)value.Variant, null, null); + break; + case "geotile_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregation?)value.Variant, null, null); + break; + case "global": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregation?)value.Variant, null, null); + break; + case "histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregation?)value.Variant, null, null); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregation?)value.Variant, null, null); + break; + case "ip_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregation?)value.Variant, null, null); + break; + case "ip_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregation?)value.Variant, null, null); + break; + case "line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation?)value.Variant, null, null); + break; + case "matrix_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation?)value.Variant, null, null); + break; + case "max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MaxAggregation?)value.Variant, null, null); + break; + case "max_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MaxBucketAggregation?)value.Variant, null, null); + break; + case "median_absolute_deviation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregation?)value.Variant, null, null); + break; + case "min": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MinAggregation?)value.Variant, null, null); + break; + case "min_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MinBucketAggregation?)value.Variant, null, null); + break; + case "missing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MissingAggregation?)value.Variant, null, null); + break; + case "moving_fn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MovingFunctionAggregation?)value.Variant, null, null); + break; + case "moving_percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MovingPercentilesAggregation?)value.Variant, null, null); + break; + case "multi_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregation?)value.Variant, null, null); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.NestedAggregation?)value.Variant, null, null); + break; + case "normalize": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.NormalizeAggregation?)value.Variant, null, null); + break; + case "parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ParentAggregation?)value.Variant, null, null); + break; + case "percentile_ranks": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentileRanksAggregation?)value.Variant, null, null); + break; + case "percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesAggregation?)value.Variant, null, null); + break; + case "percentiles_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregation?)value.Variant, null, null); + break; + case "random_sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RandomSamplerAggregation?)value.Variant, null, null); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RangeAggregation?)value.Variant, null, null); + break; + case "rare_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RareTermsAggregation?)value.Variant, null, null); + break; + case "rate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RateAggregation?)value.Variant, null, null); + break; + case "reverse_nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregation?)value.Variant, null, null); + break; + case "sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregation?)value.Variant, null, null); + break; + case "scripted_metric": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregation?)value.Variant, null, null); + break; + case "serial_diff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SerialDifferencingAggregation?)value.Variant, null, null); + break; + case "significant_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTermsAggregation?)value.Variant, null, null); + break; + case "significant_text": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTextAggregation?)value.Variant, null, null); + break; + case "stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StatsAggregation?)value.Variant, null, null); + break; + case "stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregation?)value.Variant, null, null); + break; + case "string_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregation?)value.Variant, null, null); + break; + case "sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SumAggregation?)value.Variant, null, null); + break; + case "sum_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SumBucketAggregation?)value.Variant, null, null); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TermsAggregation?)value.Variant, null, null); + break; + case "time_series": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregation?)value.Variant, null, null); + break; + case "top_hits": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregation?)value.Variant, null, null); + break; + case "top_metrics": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregation?)value.Variant, null, null); + break; + case "t_test": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TTestAggregation?)value.Variant, null, null); + break; + case "value_count": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregation?)value.Variant, null, null); + break; + case "variable_width_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregation?)value.Variant, null, null); + break; + case "weighted_avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Aggregation)}'."); } + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs index 3119d139dbc..6b9756f8e69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/AverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs index c143e3b2a1b..ab3c7a298ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/BoxplotAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs index 66c8eb6edfa..fe20d867b44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs index 1a32f623f8b..66853388aba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/BucketSortAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs index 85b70e68f2b..a3b125948fd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs @@ -27,6 +27,75 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFrom = default; + LocalJsonValue propGapPolicy = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propGapPolicy.TryReadProperty(ref reader, options, PropGapPolicy, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropGapPolicy, value.GapPolicy, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BucketSortAggregationConverter))] public sealed partial class BucketSortAggregation { /// @@ -34,7 +103,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 +110,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.Aggregations.GapPolicy? GapPolicy { get; set; } /// @@ -51,7 +118,6 @@ public sealed partial class BucketSortAggregation /// Defaults to all buckets of the parent aggregation. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -59,8 +125,6 @@ public sealed partial class BucketSortAggregation /// The list of fields to sort on. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(BucketSortAggregation bucketSortAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.BucketSort(bucketSortAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Buckets.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Buckets.g.cs index f1357abc016..e1d4a44d48d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Buckets.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Buckets.g.cs @@ -36,13 +36,66 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; /// the different buckets, the result is a dictionary. /// /// -public sealed partial class Buckets : Union, IReadOnlyCollection> +[JsonConverter(typeof(BucketsConverterFactory))] +public sealed partial class Buckets : Union, ICollection> { - public Buckets(IReadOnlyDictionary Keyed) : base(Keyed) + public Buckets(IDictionary keyed) : base(keyed) { } - public Buckets(IReadOnlyCollection Array) : base(Array) + public Buckets(ICollection array) : base(array) { } +} + +internal sealed partial class BucketsConverter : System.Text.Json.Serialization.JsonConverter> +{ + public override Buckets Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new Buckets(reader.ReadValue>(options, static IDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new Buckets(reader.ReadValue>(options, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(Buckets)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Buckets value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } +} + +internal sealed partial class BucketsConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Buckets<>); + } + + 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(BucketsConverter<>).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/_Generated/Types/Aggregations/CardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs index 945b2e1ae39..2da809d9617 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/CategorizeTextAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CategorizeTextAnalyzer.g.cs index 8cba621b3b1..d45c4b47b5d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CategorizeTextAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CategorizeTextAnalyzer.g.cs @@ -30,13 +30,52 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +[JsonConverter(typeof(CategorizeTextAnalyzerConverter))] public sealed partial class CategorizeTextAnalyzer : Union { - public CategorizeTextAnalyzer(string Builtin) : base(Builtin) + public CategorizeTextAnalyzer(string builtin) : base(builtin) { } - public CategorizeTextAnalyzer(Elastic.Clients.Elasticsearch.Aggregations.CustomCategorizeTextAnalyzer Custom) : base(Custom) + public CategorizeTextAnalyzer(Elastic.Clients.Elasticsearch.Aggregations.CustomCategorizeTextAnalyzer custom) : base(custom) { } + + public static implicit operator CategorizeTextAnalyzer(string builtin) => new CategorizeTextAnalyzer(builtin); + public static implicit operator CategorizeTextAnalyzer(Elastic.Clients.Elasticsearch.Aggregations.CustomCategorizeTextAnalyzer custom) => new CategorizeTextAnalyzer(custom); +} + +internal sealed partial class CategorizeTextAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + public override CategorizeTextAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new CategorizeTextAnalyzer(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new CategorizeTextAnalyzer(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(CategorizeTextAnalyzer)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CategorizeTextAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs index 072e2c3f5ca..25eb0f7b060 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ChildrenAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChildrenAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class ChildrenAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/CompositeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs index 600426a0e04..cc7615b34d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/CompositeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs index 42e67f51da3..f96b4bc44ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new CompositeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompositeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs index 5c0dcba229a..bc805586808 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs index f1e0896cdb3..6221ed36a4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs index a42bd78fdb7..345b2b454b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs @@ -27,6 +27,165 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCalendarInterval = default; + LocalJsonValue propExtendedBounds = default; + LocalJsonValue propField = default; + LocalJsonValue propFixedInterval = default; + LocalJsonValue propFormat = default; + LocalJsonValue propHardBounds = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propOffset = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue?> propParams = default; + LocalJsonValue propScript = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarInterval.TryReadProperty(ref reader, options, PropCalendarInterval, null)) + { + continue; + } + + if (propExtendedBounds.TryReadProperty(ref reader, options, PropExtendedBounds, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFixedInterval.TryReadProperty(ref reader, options, PropFixedInterval, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propHardBounds.TryReadProperty(ref reader, options, PropHardBounds, null)) + { + continue; + } + + if (propMinDocCount.TryReadProperty(ref reader, options, PropMinDocCount, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, null))) + { + continue; + } + + if (propParams.TryReadProperty(ref reader, options, PropParams, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propTimeZone.TryReadProperty(ref reader, options, PropTimeZone, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExtendedBounds, value.ExtendedBounds, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFixedInterval, value.FixedInterval, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropHardBounds, value.HardBounds, null, null); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteSingleOrManyCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropParams, value.Params, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropTimeZone, value.TimeZone, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateHistogramAggregationConverter))] public sealed partial class DateHistogramAggregation { /// @@ -35,7 +194,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.Aggregations.CalendarInterval? CalendarInterval { get; set; } /// @@ -43,7 +201,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.Aggregations.ExtendedBoundsDate? ExtendedBounds { get; set; } /// @@ -51,7 +208,6 @@ public sealed partial class DateHistogramAggregation /// The date field whose values are use to build a histogram. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -59,7 +215,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.Duration? FixedInterval { get; set; } /// @@ -68,7 +223,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 +230,6 @@ public sealed partial class DateHistogramAggregation /// Limits the histogram to specified bounds. /// /// - [JsonInclude, JsonPropertyName("hard_bounds")] public Elastic.Clients.Elasticsearch.Aggregations.ExtendedBoundsDate? HardBounds { get; set; } /// @@ -85,7 +238,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 +246,6 @@ public sealed partial class DateHistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public DateTimeOffset? Missing { get; set; } /// @@ -102,7 +253,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.Duration? Offset { get; set; } /// @@ -110,12 +260,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.Script? Script { get; set; } /// @@ -124,7 +270,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.Aggregations.Aggregation(DateHistogramAggregation dateHistogramAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.DateHistogram(dateHistogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs index 1c4587a37dd..0c4cce483a7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs @@ -27,56 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DateHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateHistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs index 7c01bcdd83e..e68c891098e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/DerivativeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs index 6773162c7ea..4518efd8ec8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs index cab1c43b3f6..6f5e6ebb498 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs index 7b41be3afc5..0567a85ba4f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs @@ -27,63 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCountErrorUpperBound, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DoubleTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs index bac3a657435..ab8f6273664 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs index 745361506c4..675a13cef90 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/FieldDateMath.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FieldDateMath.g.cs index 1d37920bad0..63b9cb73fcc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FieldDateMath.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FieldDateMath.g.cs @@ -36,13 +36,52 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; /// according to the target field's precision. /// /// -public sealed partial class FieldDateMath : Union +[JsonConverter(typeof(FieldDateMathConverter))] +public sealed partial class FieldDateMath : Union { - public FieldDateMath(string Expr) : base(Expr) + public FieldDateMath(Elastic.Clients.Elasticsearch.DateMath expr) : base(expr) { } - public FieldDateMath(double Value) : base(Value) + public FieldDateMath(double value) : base(value) { } + + public static implicit operator FieldDateMath(Elastic.Clients.Elasticsearch.DateMath expr) => new FieldDateMath(expr); + public static implicit operator FieldDateMath(double value) => new FieldDateMath(value); +} + +internal sealed partial class FieldDateMathConverter : System.Text.Json.Serialization.JsonConverter +{ + public override FieldDateMath Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new FieldDateMath(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new FieldDateMath(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(FieldDateMath)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldDateMath value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs index 20dac2acc0f..8564b254604 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FilterAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FilterAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class FilterAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/FiltersAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs index 7dcc5086217..92f3527f2d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/FiltersBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs index 3551b48bfdb..21978da0d8f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs @@ -27,42 +27,49 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FiltersBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FiltersBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs index 10bd279d590..1f74798ffd2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs index 88ff41a35f0..63818ba87fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs @@ -27,56 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue>> propKey = default; + LocalJsonValue propSupport = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, static IReadOnlyDictionary> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)!)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propSupport.TryReadProperty(ref reader, options, PropSupport, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FrequentItemSetsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, Support = support }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FrequentItemSetsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary> v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteProperty(options, PropSupport, value.Support, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs index ddc34a2eb4e..d32da055e1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeoBoundsAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs index 4be076472e7..094be70d111 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class GeoCentroidAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs index b3d316f4f5e..65021295d16 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/GeoLineAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs index 5191273fae9..b10bbf7fd47 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs index 5b7c3c64f79..71da7edf506 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/GeohashGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs index 8a8a6bc482c..9036912d845 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohashGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohashGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs index b70f968b98f..dcee019a9fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/GeohexGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs index 4863f027671..41b74070094 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohexGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohexGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs index ff2bbda7bd4..25650a1c804 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/GeotileGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs index 8c03fbf568d..669d2a181e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeotileGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeotileGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs index 6ba1c78191d..d061026a8a6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GlobalAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GlobalAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class GlobalAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs index dcf051f90b2..6441261ca4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs index f82bc12e77d..0ad880053f6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs index e96f1a21eda..01cd6fbc1d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/HistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs index cd3c90e0d08..e05c9d8434b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs @@ -27,6 +27,135 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propExtendedBounds = default; + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propHardBounds = default; + LocalJsonValue propInterval = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propOffset = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExtendedBounds.TryReadProperty(ref reader, options, PropExtendedBounds, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propHardBounds.TryReadProperty(ref reader, options, PropHardBounds, null)) + { + continue; + } + + if (propInterval.TryReadProperty(ref reader, options, PropInterval, null)) + { + continue; + } + + if (propMinDocCount.TryReadProperty(ref reader, options, PropMinDocCount, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, null))) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropHardBounds, value.HardBounds, null, null); + writer.WriteProperty(options, PropInterval, value.Interval, null, null); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteSingleOrManyCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HistogramAggregationConverter))] public sealed partial class HistogramAggregation { /// @@ -34,7 +163,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.Aggregations.ExtendedBoundsFloat? ExtendedBounds { get; set; } /// @@ -42,9 +170,7 @@ public sealed partial class HistogramAggregation /// The name of the field to aggregate on. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -53,7 +179,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.Aggregations.ExtendedBoundsFloat? HardBounds { get; set; } /// @@ -62,7 +187,6 @@ public sealed partial class HistogramAggregation /// Must be a positive decimal. /// /// - [JsonInclude, JsonPropertyName("interval")] public double? Interval { get; set; } /// @@ -71,7 +195,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 +203,6 @@ public sealed partial class HistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public double? Missing { get; set; } /// @@ -89,7 +211,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 +219,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.Script? Script { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(HistogramAggregation histogramAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.Histogram(histogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs index e1641587177..2f24d21bbde 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs @@ -27,56 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new HistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs index 19e7421f99a..d88fc9cb680 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs @@ -27,65 +27,89 @@ namespace Elastic.Clients.Elasticsearch.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 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.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; + LocalJsonValue?> propFeatureImportance = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue?> propTopClasses = default; + LocalJsonValue propValue = default; + LocalJsonValue propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFeatureImportance.TryReadProperty(ref reader, options, PropFeatureImportance, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (property == "value") - { - value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propTopClasses.TryReadProperty(ref reader, options, PropTopClasses, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (property == "warning") - { - warning = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propWarning.TryReadProperty(ref reader, options, PropWarning, null)) + { + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTopClasses, value.TopClasses, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropValue, value.Value, null, null); + writer.WriteProperty(options, PropWarning, value.Warning, null, null); + if (value.Data is not null) + { + foreach (var item in value.Data) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -103,4 +127,6 @@ public sealed partial class InferenceAggregate : IAggregate public IReadOnlyCollection? TopClasses { get; init; } public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs index 431c4cac795..027b6c983a1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs @@ -39,12 +39,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.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfig("classification", classificationInferenceOptions); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions regressionInferenceOptions) => new InferenceConfig("regression", regressionInferenceOptions); @@ -62,67 +66,61 @@ 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant, null, null); + 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/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs index ecd1258985b..a7e1a34d9df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/IpPrefixBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs index e03c5122173..dd73ffca63c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs @@ -27,70 +27,89 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propIsIpv6 = default; + LocalJsonValue propKey = default; + LocalJsonValue propNetmask = default; + LocalJsonValue propPrefixLength = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropIsIpv6, null)) + { + continue; + } - if (property == "prefix_length") - { - prefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propNetmask.TryReadProperty(ref reader, options, PropNetmask, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propPrefixLength.TryReadProperty(ref reader, options, PropPrefixLength, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpPrefixBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropIsIpv6, value.IsIpv6, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropNetmask, value.Netmask, null, null); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs index b29a4b1c35b..eeaf5ca6df9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/IpRangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs index ea2b231722d..524476c3186 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs @@ -27,63 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propFrom = default; + LocalJsonValue propKey = default; + LocalJsonValue propTo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propTo.TryReadProperty(ref reader, options, PropTo, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpRangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropTo, value.To, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs index 13fa685df54..2e3ba8cc6c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs index 11dc48330e5..d22549703fc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs @@ -27,56 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs index 11c3ad82fae..68f568817bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/LongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs index e6e6265dbfa..6ece09dadec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs @@ -27,63 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCountErrorUpperBound, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs index 6b941174faf..bf3ee2fe366 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs index db56e60d7af..22dc3b615e1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs @@ -27,6 +27,65 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFields = default; + LocalJsonValue?> propMissing = default; + LocalJsonValue propMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propMode.TryReadProperty(ref reader, options, PropMode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropMissing, value.Missing, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropMode, value.Mode, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MatrixStatsAggregationConverter))] public sealed partial class MatrixStatsAggregation { /// @@ -34,8 +93,6 @@ public sealed partial class MatrixStatsAggregation /// An array of fields for computing the statistics. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -44,7 +101,6 @@ public sealed partial class MatrixStatsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public IDictionary? Missing { get; set; } /// @@ -52,7 +108,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.SortMode? Mode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(MatrixStatsAggregation matrixStatsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.MatrixStats(matrixStatsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs index f1b01e2dbb5..281880059ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs @@ -30,12 +30,10 @@ namespace Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/MaxAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs index cddda334221..bc132975c80 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs index 4d868eea1db..add5e70c90f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/MinAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs index 08ab4f8d939..977bcf74f06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/MissingAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs index 230547ba313..dca28d904df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MissingAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MissingAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class MissingAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs index 8b9a14cd9a2..db9b5ed3a40 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs index 962a8a079e2..3d70b218786 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCollectMode = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propShowTermDocCountError = default; + LocalJsonValue propSize = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryReadProperty(ref reader, options, PropCollectMode, null)) + { + continue; + } + + if (propMinDocCount.TryReadProperty(ref reader, options, PropMinDocCount, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, null))) + { + continue; + } + + if (propShardMinDocCount.TryReadProperty(ref reader, options, PropShardMinDocCount, null)) + { + continue; + } + + if (propShardSize.TryReadProperty(ref reader, options, PropShardSize, null)) + { + continue; + } + + if (propShowTermDocCountError.TryReadProperty(ref reader, options, PropShowTermDocCountError, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propTerms.TryReadProperty(ref reader, options, PropTerms, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteSingleOrManyCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount, null, null); + writer.WriteProperty(options, PropShardSize, value.ShardSize, null, null); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropTerms, value.Terms, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermsAggregationConverter))] public sealed partial class MultiTermsAggregation { /// @@ -34,7 +143,6 @@ public sealed partial class MultiTermsAggregation /// Specifies the strategy for data collection. /// /// - [JsonInclude, JsonPropertyName("collect_mode")] public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -42,7 +150,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 +158,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 +165,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 +173,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 +180,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 +187,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 +194,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.Aggregations.Aggregation(MultiTermsAggregation multiTermsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.MultiTerms(multiTermsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs index 003b8283ea2..d063cd5218c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs @@ -27,63 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue> propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCountErrorUpperBound, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MultiTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs index e38814bec14..ca72c9b32a2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new NestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class NestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/ParentAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs index 33739b8289d..59696426e61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ParentAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ParentAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class ParentAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/Percentiles.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Percentiles.g.cs index f74611a4c27..692f46b024f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Percentiles.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Percentiles.g.cs @@ -30,13 +30,49 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +[JsonConverter(typeof(PercentilesConverter))] public sealed partial class Percentiles : Union, IReadOnlyCollection> { - public Percentiles(IReadOnlyDictionary Keyed) : base(Keyed) + public Percentiles(IReadOnlyDictionary keyed) : base(keyed) { } - public Percentiles(IReadOnlyCollection Array) : base(Array) + public Percentiles(IReadOnlyCollection array) : base(array) { } -} \ No newline at end of file +} + +internal sealed partial class PercentilesConverter : System.Text.Json.Serialization.JsonConverter +{ + public override Percentiles Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new Percentiles(reader.ReadValue>(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new Percentiles(reader.ReadValue>(options, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(Percentiles)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Percentiles value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } +} diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs index bed01ff53b2..a287e24e293 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "percentiles_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs index e9df9b37862..4de004441cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/RangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs index b8079e6ad04..36a7a4346a7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs @@ -27,77 +27,99 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propFrom = default; + LocalJsonValue propFromAsString = default; + LocalJsonValue propKey = default; + LocalJsonValue propTo = default; + LocalJsonValue propToAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) + { + continue; + } + + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propFromAsString.TryReadProperty(ref reader, options, PropFromAsString, null)) + { + continue; + } + + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) { - 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.TryReadProperty(ref reader, options, PropTo, null)) + { + continue; + } + + if (propToAsString.TryReadProperty(ref reader, options, PropToAsString, null)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new RangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropFromAsString, value.FromAsString, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropTo, value.To, null, null); + writer.WriteProperty(options, PropToAsString, value.ToAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs index 4718e6f1823..a6459e2ae44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs index ec6aff078dd..45f3b6360dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ReverseNestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReverseNestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class ReverseNestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/SamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs index 422f7d9a8df..74e4131f42e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class SamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs index 64ca2bf26ce..d5ec9eaf5a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs index 04c561fc339..3ffae488fb0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs index bc249c8d098..9ea6e25db08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs @@ -27,70 +27,89 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propBgCount = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + LocalJsonValue propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryReadProperty(ref reader, options, PropBgCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCount, null)) + { + continue; + } - if (property == "score") - { - score = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryReadProperty(ref reader, options, PropScore, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantLongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropDocCount, value.DocCount, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + writer.WriteProperty(options, PropScore, value.Score, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs index e2e799a941e..661f9002353 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs index 557a647c326..c8a2e7eb718 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs @@ -27,63 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propBgCount = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryReadProperty(ref reader, options, PropBgCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCount, null)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryReadProperty(ref reader, options, PropScore, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantStringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropDocCount, value.DocCount, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropScore, value.Score, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs index 09fa408e2cf..ee56b76e92c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs @@ -27,6 +27,205 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBackgroundFilter = default; + LocalJsonValue propChiSquare = default; + LocalJsonValue propExclude = default; + LocalJsonValue propExecutionHint = default; + LocalJsonValue propField = default; + LocalJsonValue propFilterDuplicateText = default; + LocalJsonValue propGnd = default; + LocalJsonValue propInclude = default; + LocalJsonValue propJlh = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMutualInformation = default; + LocalJsonValue propPercentage = default; + LocalJsonValue propScriptHeuristic = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propSize = default; + LocalJsonValue propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackgroundFilter.TryReadProperty(ref reader, options, PropBackgroundFilter, null)) + { + continue; + } + + if (propChiSquare.TryReadProperty(ref reader, options, PropChiSquare, null)) + { + continue; + } + + if (propExclude.TryReadProperty(ref reader, options, PropExclude, null)) + { + continue; + } + + if (propExecutionHint.TryReadProperty(ref reader, options, PropExecutionHint, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFilterDuplicateText.TryReadProperty(ref reader, options, PropFilterDuplicateText, null)) + { + continue; + } + + if (propGnd.TryReadProperty(ref reader, options, PropGnd, null)) + { + continue; + } + + if (propInclude.TryReadProperty(ref reader, options, PropInclude, null)) + { + continue; + } + + if (propJlh.TryReadProperty(ref reader, options, PropJlh, null)) + { + continue; + } + + if (propMinDocCount.TryReadProperty(ref reader, options, PropMinDocCount, null)) + { + continue; + } + + if (propMutualInformation.TryReadProperty(ref reader, options, PropMutualInformation, null)) + { + continue; + } + + if (propPercentage.TryReadProperty(ref reader, options, PropPercentage, null)) + { + continue; + } + + if (propScriptHeuristic.TryReadProperty(ref reader, options, PropScriptHeuristic, null)) + { + continue; + } + + if (propShardMinDocCount.TryReadProperty(ref reader, options, PropShardMinDocCount, null)) + { + continue; + } + + if (propShardSize.TryReadProperty(ref reader, options, PropShardSize, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSourceFields.TryReadProperty(ref reader, options, PropSourceFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropChiSquare, value.ChiSquare, null, null); + writer.WriteProperty(options, PropExclude, value.Exclude, null, null); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFilterDuplicateText, value.FilterDuplicateText, null, null); + writer.WriteProperty(options, PropGnd, value.Gnd, null, null); + writer.WriteProperty(options, PropInclude, value.Include, null, null); + writer.WriteProperty(options, PropJlh, value.Jlh, null, null); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount, null, null); + writer.WriteProperty(options, PropMutualInformation, value.MutualInformation, null, null); + writer.WriteProperty(options, PropPercentage, value.Percentage, null, null); + writer.WriteProperty(options, PropScriptHeuristic, value.ScriptHeuristic, null, null); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount, null, null); + writer.WriteProperty(options, PropShardSize, value.ShardSize, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SignificantTextAggregationConverter))] public sealed partial class SignificantTextAggregation { /// @@ -34,7 +233,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.QueryDsl.Query? BackgroundFilter { get; set; } /// @@ -42,7 +240,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.Aggregations.ChiSquareHeuristic? ChiSquare { get; set; } /// @@ -50,7 +247,6 @@ public sealed partial class SignificantTextAggregation /// Values to exclude. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -58,7 +254,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.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -66,7 +261,6 @@ public sealed partial class SignificantTextAggregation /// The field from which to return significant text. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -74,7 +268,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 +275,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.Aggregations.GoogleNormalizedDistanceHeuristic? Gnd { get; set; } /// @@ -90,7 +282,6 @@ public sealed partial class SignificantTextAggregation /// Values to include. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? Include { get; set; } /// @@ -98,7 +289,6 @@ public sealed partial class SignificantTextAggregation /// Use JLH score as the significance score. /// /// - [JsonInclude, JsonPropertyName("jlh")] public Elastic.Clients.Elasticsearch.EmptyObject? Jlh { get; set; } /// @@ -106,7 +296,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 +303,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.Aggregations.MutualInformationHeuristic? MutualInformation { get; set; } /// @@ -122,7 +310,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.Aggregations.PercentageScoreHeuristic? Percentage { get; set; } /// @@ -130,7 +317,6 @@ public sealed partial class SignificantTextAggregation /// Customized score, implemented via a script. /// /// - [JsonInclude, JsonPropertyName("script_heuristic")] public Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? ScriptHeuristic { get; set; } /// @@ -139,7 +325,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 +333,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 +340,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 +347,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.Fields? SourceFields { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(SignificantTextAggregation significantTextAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.SignificantText(significantTextAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs index 00e7be7375c..bb3f6596d98 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs index 35562889db5..91517ba499c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs index ec9d642824d..09b53f1f69c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs index 405760fb953..6a18899063a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs index f704ddde80d..306da30bbd0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs index 2bcd1cd10f5..e14b0af63ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs index 91cc63038f0..c6fd70e6a53 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/StringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs index 72ce873ca08..7dadaef112f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs @@ -27,56 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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.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; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropDocCountErrorUpperBound, null)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs index 23cb1250502..e5eae8deea3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs index b38f73b6d5a..13948b12299 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs index 4a7003596af..4dc5e72c56a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs index a152f0c5218..0d047c25331 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/TermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs index f49f740db06..fa54e1637a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs @@ -27,6 +27,205 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCollectMode = default; + LocalJsonValue propExclude = default; + LocalJsonValue propExecutionHint = default; + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propInclude = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propMissingBucket = default; + LocalJsonValue propMissingOrder = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propScript = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propShowTermDocCountError = default; + LocalJsonValue propSize = default; + LocalJsonValue propValueType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryReadProperty(ref reader, options, PropCollectMode, null)) + { + continue; + } + + if (propExclude.TryReadProperty(ref reader, options, PropExclude, null)) + { + continue; + } + + if (propExecutionHint.TryReadProperty(ref reader, options, PropExecutionHint, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propInclude.TryReadProperty(ref reader, options, PropInclude, null)) + { + continue; + } + + if (propMinDocCount.TryReadProperty(ref reader, options, PropMinDocCount, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propMissingBucket.TryReadProperty(ref reader, options, PropMissingBucket, null)) + { + continue; + } + + if (propMissingOrder.TryReadProperty(ref reader, options, PropMissingOrder, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, null))) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propShardMinDocCount.TryReadProperty(ref reader, options, PropShardMinDocCount, null)) + { + continue; + } + + if (propShardSize.TryReadProperty(ref reader, options, PropShardSize, null)) + { + continue; + } + + if (propShowTermDocCountError.TryReadProperty(ref reader, options, PropShowTermDocCountError, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propValueType.TryReadProperty(ref reader, options, PropValueType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExclude, value.Exclude, null, null); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropInclude, value.Include, null, null); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropMissingBucket, value.MissingBucket, null, null); + writer.WriteProperty(options, PropMissingOrder, value.MissingOrder, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteSingleOrManyCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount, null, null); + writer.WriteProperty(options, PropShardSize, value.ShardSize, null, null); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropValueType, value.ValueType, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsAggregationConverter))] public sealed partial class TermsAggregation { /// @@ -34,7 +233,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.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -43,7 +241,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -51,7 +248,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.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -59,9 +255,7 @@ public sealed partial class TermsAggregation /// The field from which to return terms. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -70,7 +264,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? Include { get; set; } /// @@ -78,7 +271,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 +279,8 @@ public sealed partial class TermsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("missing_bucket")] public bool? MissingBucket { get; set; } - [JsonInclude, JsonPropertyName("missing_order")] public Elastic.Clients.Elasticsearch.Aggregations.MissingOrder? MissingOrder { get; set; } /// @@ -100,10 +289,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.Script? Script { get; set; } /// @@ -112,7 +298,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 +306,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 +313,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 +320,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 +327,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.Aggregations.Aggregation(TermsAggregation termsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.Terms(termsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs index bd927b7576c..cffb8e524c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs index 3b391a5494c..dca0d65ac0e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropKey, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new TimeSeriesBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TimeSeriesBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs index 5a7011780ff..b2fc7bde46f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TopHitsAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/TopHitsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs index 60bdfb33f43..58569023947 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs @@ -27,6 +27,195 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propMissing = default; + LocalJsonValue propScript = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocvalueFields.TryReadProperty(ref reader, options, PropDocvalueFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryReadProperty(ref reader, options, PropSeqNoPrimaryTerm, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propTrackScores.TryReadProperty(ref reader, options, PropTrackScores, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropTrackScores, value.TrackScores, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopHitsAggregationConverter))] public sealed partial class TopHitsAggregation { /// @@ -34,7 +223,6 @@ public sealed partial class TopHitsAggregation /// Fields for which to return doc values. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -42,7 +230,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 +237,6 @@ public sealed partial class TopHitsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -59,7 +245,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 +252,6 @@ public sealed partial class TopHitsAggregation /// Starting document offset. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -75,7 +259,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.Core.Search.Highlight? Highlight { get; set; } /// @@ -84,9 +267,7 @@ public sealed partial class TopHitsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -94,7 +275,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 +282,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 +289,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 +297,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.SortOptions))] public ICollection? Sort { get; set; } /// @@ -128,7 +304,6 @@ public sealed partial class TopHitsAggregation /// Selects the fields of the source that are returned. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -136,8 +311,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.Fields? StoredFields { get; set; } /// @@ -145,7 +318,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 +325,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.Aggregations.Aggregation(TopHitsAggregation topHitsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.TopHits(topHitsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs index 3675a8b9148..82797613d28 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs index d063b3c1be9..e2a908beaac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs @@ -27,6 +27,95 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propField = default; + LocalJsonValue?> propMetrics = default; + LocalJsonValue propMissing = default; + LocalJsonValue propScript = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propMetrics.TryReadProperty(ref reader, options, PropMetrics, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropMetrics, value.Metrics, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopMetricsAggregationConverter))] public sealed partial class TopMetricsAggregation { /// @@ -34,7 +123,6 @@ public sealed partial class TopMetricsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -42,8 +130,6 @@ public sealed partial class TopMetricsAggregation /// The fields of the top document to return. /// /// - [JsonInclude, JsonPropertyName("metrics")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.TopMetricsValue))] public ICollection? Metrics { get; set; } /// @@ -52,9 +138,7 @@ public sealed partial class TopMetricsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -62,7 +146,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 +153,6 @@ public sealed partial class TopMetricsAggregation /// The sort order of the documents. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(TopMetricsAggregation topMetricsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.TopMetrics(topMetricsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs index 65f49279fe6..da3578e0e08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs index 49e77c3a953..e2c1e998058 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs @@ -27,49 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) { - 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.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new UnmappedSamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnmappedSamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.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, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +94,6 @@ public sealed partial class UnmappedSamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.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/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs index 61265ed8a92..a5d5bc23fd8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs index 58914563b27..2bbd309b511 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/ValueCountAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs index 697e951c703..5ee4872a5c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs index 5501a87a5b2..52845a6dd69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs index 4d1f82516da..16c61cd6022 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs @@ -27,84 +27,109 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + LocalJsonValue propMax = default; + LocalJsonValue propMaxAsString = default; + LocalJsonValue propMin = default; + LocalJsonValue propMinAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryReadProperty(ref reader, options, PropDocCount, null)) + { + continue; + } + + if (propKey.TryReadProperty(ref reader, options, PropKey, null)) + { + continue; + } + + if (propKeyAsString.TryReadProperty(ref reader, options, PropKeyAsString, null)) + { + continue; + } + + if (propMax.TryReadProperty(ref reader, options, PropMax, null)) + { + continue; + } + + if (propMaxAsString.TryReadProperty(ref reader, options, PropMaxAsString, null)) { - 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.TryReadProperty(ref reader, options, PropMin, null)) + { + continue; + } + + if (propMinAsString.TryReadProperty(ref reader, options, PropMinAsString, null)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new VariableWidthHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.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.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, null, null); + writer.WriteProperty(options, PropKey, value.Key, null, null); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString, null, null); + writer.WriteProperty(options, PropMax, value.Max, null, null); + writer.WriteProperty(options, PropMaxAsString, value.MaxAsString, null, null); + writer.WriteProperty(options, PropMin, value.Min, null, null); + writer.WriteProperty(options, PropMinAsString, value.MinAsString, null, null); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs index 673773b6806..e3cad85c268 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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/_Generated/Types/Analysis/Analyzers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs index aaec84a9912..69584c11568 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs @@ -218,289 +218,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, null)) + { + 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, null), + "armenian" => reader.ReadValue(options, null), + "basque" => reader.ReadValue(options, null), + "bengali" => reader.ReadValue(options, null), + "brazilian" => reader.ReadValue(options, null), + "bulgarian" => reader.ReadValue(options, null), + "catalan" => reader.ReadValue(options, null), + "chinese" => reader.ReadValue(options, null), + "cjk" => reader.ReadValue(options, null), + "custom" => reader.ReadValue(options, null), + "czech" => reader.ReadValue(options, null), + "danish" => reader.ReadValue(options, null), + "dutch" => reader.ReadValue(options, null), + "english" => reader.ReadValue(options, null), + "estonian" => reader.ReadValue(options, null), + "fingerprint" => reader.ReadValue(options, null), + "finnish" => reader.ReadValue(options, null), + "french" => reader.ReadValue(options, null), + "galician" => reader.ReadValue(options, null), + "german" => reader.ReadValue(options, null), + "greek" => reader.ReadValue(options, null), + "hindi" => reader.ReadValue(options, null), + "hungarian" => reader.ReadValue(options, null), + "icu_analyzer" => reader.ReadValue(options, null), + "indonesian" => reader.ReadValue(options, null), + "irish" => reader.ReadValue(options, null), + "italian" => reader.ReadValue(options, null), + "keyword" => reader.ReadValue(options, null), + "kuromoji" => reader.ReadValue(options, null), + "language" => reader.ReadValue(options, null), + "latvian" => reader.ReadValue(options, null), + "lithuanian" => reader.ReadValue(options, null), + "nori" => reader.ReadValue(options, null), + "norwegian" => reader.ReadValue(options, null), + "pattern" => reader.ReadValue(options, null), + "persian" => reader.ReadValue(options, null), + "portuguese" => reader.ReadValue(options, null), + "romanian" => reader.ReadValue(options, null), + "russian" => reader.ReadValue(options, null), + "serbian" => reader.ReadValue(options, null), + "simple" => reader.ReadValue(options, null), + "snowball" => reader.ReadValue(options, null), + "sorani" => reader.ReadValue(options, null), + "spanish" => reader.ReadValue(options, null), + "standard" => reader.ReadValue(options, null), + "stop" => reader.ReadValue(options, null), + "swedish" => reader.ReadValue(options, null), + "thai" => reader.ReadValue(options, null), + "turkish" => reader.ReadValue(options, null), + "whitespace" => reader.ReadValue(options, null), + _ => 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.Analysis.ArabicAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ArabicAnalyzer)value, null); + break; case "armenian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ArmenianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ArmenianAnalyzer)value, null); + break; case "basque": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BasqueAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BasqueAnalyzer)value, null); + break; case "bengali": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BengaliAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BengaliAnalyzer)value, null); + break; case "brazilian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BrazilianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BrazilianAnalyzer)value, null); + break; case "bulgarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BulgarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BulgarianAnalyzer)value, null); + break; case "catalan": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CatalanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CatalanAnalyzer)value, null); + break; case "chinese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ChineseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ChineseAnalyzer)value, null); + break; case "cjk": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CjkAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CjkAnalyzer)value, null); + break; case "custom": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CustomAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CustomAnalyzer)value, null); + break; case "czech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CzechAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CzechAnalyzer)value, null); + break; case "danish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DanishAnalyzer)value, null); + break; case "dutch": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DutchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DutchAnalyzer)value, null); + break; case "english": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EnglishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EnglishAnalyzer)value, null); + break; case "estonian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EstonianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EstonianAnalyzer)value, null); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FingerprintAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FingerprintAnalyzer)value, null); + break; case "finnish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FinnishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FinnishAnalyzer)value, null); + break; case "french": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FrenchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FrenchAnalyzer)value, null); + break; case "galician": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GalicianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GalicianAnalyzer)value, null); + break; case "german": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GermanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GermanAnalyzer)value, null); + break; case "greek": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GreekAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GreekAnalyzer)value, null); + break; case "hindi": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HindiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HindiAnalyzer)value, null); + break; case "hungarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HungarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HungarianAnalyzer)value, null); + break; case "icu_analyzer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuAnalyzer)value, null); + break; case "indonesian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IndonesianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IndonesianAnalyzer)value, null); + break; case "irish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IrishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IrishAnalyzer)value, null); + break; case "italian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ItalianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ItalianAnalyzer)value, null); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordAnalyzer)value, null); + break; case "kuromoji": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiAnalyzer)value, null); + break; case "language": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LanguageAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LanguageAnalyzer)value, null); + break; case "latvian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LatvianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LatvianAnalyzer)value, null); + break; case "lithuanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LithuanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LithuanianAnalyzer)value, null); + break; case "nori": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriAnalyzer)value, null); + break; case "norwegian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NorwegianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NorwegianAnalyzer)value, null); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternAnalyzer)value, null); + break; case "persian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PersianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PersianAnalyzer)value, null); + break; case "portuguese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PortugueseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PortugueseAnalyzer)value, null); + break; case "romanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RomanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RomanianAnalyzer)value, null); + break; case "russian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RussianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RussianAnalyzer)value, null); + break; case "serbian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SerbianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SerbianAnalyzer)value, null); + break; case "simple": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimpleAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimpleAnalyzer)value, null); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SnowballAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SnowballAnalyzer)value, null); + break; case "sorani": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SoraniAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SoraniAnalyzer)value, null); + break; case "spanish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SpanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SpanishAnalyzer)value, null); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StandardAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StandardAnalyzer)value, null); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StopAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StopAnalyzer)value, null); + break; case "swedish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SwedishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SwedishAnalyzer)value, null); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ThaiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ThaiAnalyzer)value, null); + break; case "turkish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TurkishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TurkishAnalyzer)value, null); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer)value, null); + 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/_Generated/Types/Analysis/ArabicAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs index 64f5991c499..2d3d35f184f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs index 3641734436a..fbd1959d297 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/BasqueAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs index 9bdabb5b6ef..4096d2d5dda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/BengaliAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs index a9393e534cc..5abae3ebbc3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs index edb89e4c735..0b91ecb90dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs index 7d08a972858..5540c899b78 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/CatalanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs index d6215912130..05b31b0384b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/CharFilters.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs index 893e7f01f76..9bb9767c203 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs @@ -83,65 +83,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, null)) + { + 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, null), + "icu_normalizer" => reader.ReadValue(options, null), + "kuromoji_iteration_mark" => reader.ReadValue(options, null), + "mapping" => reader.ReadValue(options, null), + "pattern_replace" => reader.ReadValue(options, null), + _ => 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.Analysis.HtmlStripCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HtmlStripCharFilter)value, null); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationCharFilter)value, null); + break; case "kuromoji_iteration_mark": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiIterationMarkCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiIterationMarkCharFilter)value, null); + break; case "mapping": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.MappingCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.MappingCharFilter)value, null); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter)value, null); + 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/_Generated/Types/Analysis/ChineseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs index 8a70c33dd66..c5f58fdaa13 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/CjkAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs index 3fb380874ff..158a0035937 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/CustomAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs index ba1549ff6a7..6c1d588d4c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs @@ -27,22 +27,101 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propCharFilter = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propPositionOffsetGap = default; + LocalJsonValue propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharFilter.TryReadProperty(ref reader, options, PropCharFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propPositionIncrementGap.TryReadProperty(ref reader, options, PropPositionIncrementGap, null)) + { + continue; + } + + if (propPositionOffsetGap.TryReadProperty(ref reader, options, PropPositionOffsetGap, null)) + { + continue; + } + + if (propTokenizer.TryReadProperty(ref reader, options, PropTokenizer, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap, null, null); + writer.WriteProperty(options, PropPositionOffsetGap, value.PositionOffsetGap, null, null); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/CzechAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs index 85203810347..39ff1a8a10b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/DanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs index 96f1845395b..47982facacf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/DutchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs index 7fdbe496526..01bf805482b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/EnglishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs index bf63091004e..917e9647550 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/EstonianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs index a1e4374a3f5..add8a62e0ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs index f91086db2f4..11af0bd6f2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs @@ -27,24 +27,113 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propMaxOutputSize = default; + LocalJsonValue propPreserveOriginal = default; + LocalJsonValue propSeparator = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxOutputSize.TryReadProperty(ref reader, options, PropMaxOutputSize, null)) + { + continue; + } + + if (propPreserveOriginal.TryReadProperty(ref reader, options, PropPreserveOriginal, null)) + { + continue; + } + + if (propSeparator.TryReadProperty(ref reader, options, PropSeparator, null)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropPreserveOriginal, value.PreserveOriginal, null, null); + writer.WriteProperty(options, PropSeparator, value.Separator, null, null); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/Analysis/FinnishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs index 26daf3595db..04bff227846 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/FrenchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs index 71a3152f6f5..ded13bb70be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/GalicianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs index f1ddff66f9b..91e3fbf60ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/GermanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs index bd0b04a470f..46d83f2d772 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/GreekAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs index 89b4442eddd..4ebeaa8f9f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/HindiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs index c3142b0a785..c747caf1d12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/HungarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs index 1df50363051..d7168d0e057 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs index a970bc92251..24f99016725 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/IrishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs index eb1d2959527..08292766abe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/ItalianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs index f3c6ac186c8..68b174e9617 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs index 91a70863b7f..dc5c277346d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs @@ -27,22 +27,102 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propIgnoreCase = default; + LocalJsonValue?> propKeywords = default; + LocalJsonValue propKeywordsPath = default; + LocalJsonValue propKeywordsPattern = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryReadProperty(ref reader, options, PropIgnoreCase, null)) + { + continue; + } + + if (propKeywords.TryReadProperty(ref reader, options, PropKeywords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propKeywordsPath.TryReadProperty(ref reader, options, PropKeywordsPath, null)) + { + continue; + } + + if (propKeywordsPattern.TryReadProperty(ref reader, options, PropKeywordsPattern, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropKeywords, value.Keywords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropKeywordsPath, value.KeywordsPath, null, null); + writer.WriteProperty(options, PropKeywordsPattern, value.KeywordsPattern, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/Analysis/LanguageAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs index 00a6d5a7171..09733595fa8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs @@ -27,22 +27,102 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLanguage = default; + LocalJsonValue> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryReadProperty(ref reader, options, PropLanguage, null)) + { + continue; + } + + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LanguageAnalyzerConverter))] public sealed partial class LanguageAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Analysis/LatvianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs index 760fd6484b5..f8b0c28b8a1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs index 4a5f774ff5d..6adff12d6ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/Normalizers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs index e32a1cbe1ac..828e2848331 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs @@ -74,49 +74,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, null)) + { + 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, null), + "lowercase" => reader.ReadValue(options, null), + _ => 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.Analysis.CustomNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CustomNormalizer)value, null); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseNormalizer)value, null); + 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/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs index 873ae454f84..b971956cb1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/PatternAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs index 90b4f9f3e43..d28b21c5e61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs @@ -27,22 +27,102 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFlags = default; + LocalJsonValue propLowercase = default; + LocalJsonValue propPattern = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlags.TryReadProperty(ref reader, options, PropFlags, null)) + { + continue; + } + + if (propLowercase.TryReadProperty(ref reader, options, PropLowercase, null)) + { + continue; + } + + if (propPattern.TryReadProperty(ref reader, options, PropPattern, null)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropLowercase, value.Lowercase, null, null); + writer.WriteProperty(options, PropPattern, value.Pattern, null, null); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/Analysis/PersianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs index f889fe2782e..c08f6f5f422 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs index edc88d5e128..38ace281186 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs @@ -27,26 +27,124 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propEncoder = default; + LocalJsonValue?> propLanguageset = default; + LocalJsonValue propMaxCodeLen = default; + LocalJsonValue propNameType = default; + LocalJsonValue propReplace = default; + LocalJsonValue propRuleType = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEncoder.TryReadProperty(ref reader, options, PropEncoder, null)) + { + continue; + } + + if (propLanguageset.TryReadProperty(ref reader, options, PropLanguageset, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMaxCodeLen.TryReadProperty(ref reader, options, PropMaxCodeLen, null)) + { + continue; + } + + if (propNameType.TryReadProperty(ref reader, options, PropNameType, null)) + { + continue; + } + + if (propReplace.TryReadProperty(ref reader, options, PropReplace, null)) + { + continue; + } + + if (propRuleType.TryReadProperty(ref reader, options, PropRuleType, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropLanguageset, value.Languageset, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMaxCodeLen, value.MaxCodeLen, null, null); + writer.WriteProperty(options, PropNameType, value.NameType, null, null); + writer.WriteProperty(options, PropReplace, value.Replace, null, null); + writer.WriteProperty(options, PropRuleType, value.RuleType, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhoneticTokenFilterConverter))] public sealed partial class PhoneticTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("encoder")] public Elastic.Clients.Elasticsearch.Analysis.PhoneticEncoder Encoder { get; set; } - [JsonInclude, JsonPropertyName("languageset")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.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.Analysis.PhoneticNameType? NameType { get; set; } - [JsonInclude, JsonPropertyName("replace")] public bool? Replace { get; set; } - [JsonInclude, JsonPropertyName("rule_type")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs index 871b8aefa64..e93440cadd4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/RomanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs index b7b3a587660..c92d72ac8da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/RussianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs index b1c60d62fb8..ea0eb98a30a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/SerbianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs index 26cfb2729d5..0e9406dde29 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/SnowballAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs index f816558cc40..22fe4f9f45f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs @@ -27,18 +27,80 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLanguage = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryReadProperty(ref reader, options, PropLanguage, null)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SnowballAnalyzerConverter))] public sealed partial class SnowballAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Analysis/SoraniAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs index af879465e82..53306249362 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/SpanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs index bba23e77175..f37b51a1111 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/StandardAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs index f89bcc5f1ec..e837dd5eb01 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propMaxTokenLength = default; + LocalJsonValue?> propStopwords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxTokenLength.TryReadProperty(ref reader, options, PropMaxTokenLength, null)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/StemmerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs index b92fc84576f..f79f206f97b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs @@ -27,52 +27,59 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLanguage = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propLanguage.TryReadProperty(ref reader, options, PropLanguage, null) || propLanguage.TryReadProperty(ref reader, options, PropLanguage1, null)) { - 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.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs index 9467b26a75b..ac3b462ebe7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs @@ -27,18 +27,80 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/Analysis/StopTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs index d1093f2ebef..accaa8f084c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs @@ -27,22 +27,102 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propIgnoreCase = default; + LocalJsonValue propRemoveTrailing = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryReadProperty(ref reader, options, PropIgnoreCase, null)) + { + continue; + } + + if (propRemoveTrailing.TryReadProperty(ref reader, options, PropRemoveTrailing, null)) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropRemoveTrailing, value.RemoveTrailing, null, null); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/Analysis/SwedishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs index 1158c84638a..146126afc6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/ThaiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs index 6ce5aceb322..231c9eaa932 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs @@ -27,15 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Analysis/TokenFilters.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs index 2fa0d6a043c..69ca5a151b0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs @@ -209,275 +209,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, null)) + { + 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, null), + "common_grams" => reader.ReadValue(options, null), + "condition" => reader.ReadValue(options, null), + "delimited_payload" => reader.ReadValue(options, null), + "dictionary_decompounder" => reader.ReadValue(options, null), + "edge_ngram" => reader.ReadValue(options, null), + "elision" => reader.ReadValue(options, null), + "fingerprint" => reader.ReadValue(options, null), + "hunspell" => reader.ReadValue(options, null), + "hyphenation_decompounder" => reader.ReadValue(options, null), + "icu_collation" => reader.ReadValue(options, null), + "icu_folding" => reader.ReadValue(options, null), + "icu_normalizer" => reader.ReadValue(options, null), + "icu_transform" => reader.ReadValue(options, null), + "keep_types" => reader.ReadValue(options, null), + "keep" => reader.ReadValue(options, null), + "keyword_marker" => reader.ReadValue(options, null), + "kstem" => reader.ReadValue(options, null), + "kuromoji_part_of_speech" => reader.ReadValue(options, null), + "kuromoji_readingform" => reader.ReadValue(options, null), + "kuromoji_stemmer" => reader.ReadValue(options, null), + "length" => reader.ReadValue(options, null), + "limit" => reader.ReadValue(options, null), + "lowercase" => reader.ReadValue(options, null), + "multiplexer" => reader.ReadValue(options, null), + "ngram" => reader.ReadValue(options, null), + "nori_part_of_speech" => reader.ReadValue(options, null), + "pattern_capture" => reader.ReadValue(options, null), + "pattern_replace" => reader.ReadValue(options, null), + "phonetic" => reader.ReadValue(options, null), + "porter_stem" => reader.ReadValue(options, null), + "predicate_token_filter" => reader.ReadValue(options, null), + "remove_duplicates" => reader.ReadValue(options, null), + "reverse" => reader.ReadValue(options, null), + "shingle" => reader.ReadValue(options, null), + "snowball" => reader.ReadValue(options, null), + "stemmer_override" => reader.ReadValue(options, null), + "stemmer" => reader.ReadValue(options, null), + "stop" => reader.ReadValue(options, null), + "synonym_graph" => reader.ReadValue(options, null), + "synonym" => reader.ReadValue(options, null), + "trim" => reader.ReadValue(options, null), + "truncate" => reader.ReadValue(options, null), + "unique" => reader.ReadValue(options, null), + "uppercase" => reader.ReadValue(options, null), + "word_delimiter_graph" => reader.ReadValue(options, null), + "word_delimiter" => reader.ReadValue(options, null), + _ => 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.Analysis.AsciiFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.AsciiFoldingTokenFilter)value, null); + break; case "common_grams": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CommonGramsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CommonGramsTokenFilter)value, null); + break; case "condition": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ConditionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ConditionTokenFilter)value, null); + break; case "delimited_payload": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DelimitedPayloadTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DelimitedPayloadTokenFilter)value, null); + break; case "dictionary_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DictionaryDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DictionaryDecompounderTokenFilter)value, null); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenFilter)value, null); + break; case "elision": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ElisionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ElisionTokenFilter)value, null); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FingerprintTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FingerprintTokenFilter)value, null); + break; case "hunspell": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HunspellTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HunspellTokenFilter)value, null); + break; case "hyphenation_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HyphenationDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HyphenationDecompounderTokenFilter)value, null); + break; case "icu_collation": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuCollationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuCollationTokenFilter)value, null); + break; case "icu_folding": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuFoldingTokenFilter)value, null); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationTokenFilter)value, null); + break; case "icu_transform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuTransformTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuTransformTokenFilter)value, null); + break; case "keep_types": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeepTypesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeepTypesTokenFilter)value, null); + break; case "keep": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeepWordsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeepWordsTokenFilter)value, null); + break; case "keyword_marker": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordMarkerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordMarkerTokenFilter)value, null); + break; case "kstem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KStemTokenFilter)value, null); + break; case "kuromoji_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiPartOfSpeechTokenFilter)value, null); + break; case "kuromoji_readingform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiReadingFormTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiReadingFormTokenFilter)value, null); + break; case "kuromoji_stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiStemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiStemmerTokenFilter)value, null); + break; case "length": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LengthTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LengthTokenFilter)value, null); + break; case "limit": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LimitTokenCountTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LimitTokenCountTokenFilter)value, null); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenFilter)value, null); + break; case "multiplexer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.MultiplexerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.MultiplexerTokenFilter)value, null); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NGramTokenFilter)value, null); + break; case "nori_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriPartOfSpeechTokenFilter)value, null); + break; case "pattern_capture": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternCaptureTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternCaptureTokenFilter)value, null); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternReplaceTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternReplaceTokenFilter)value, null); + break; case "phonetic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PhoneticTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PhoneticTokenFilter)value, null); + break; case "porter_stem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PorterStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PorterStemTokenFilter)value, null); + break; case "predicate_token_filter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PredicateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PredicateTokenFilter)value, null); + break; case "remove_duplicates": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RemoveDuplicatesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RemoveDuplicatesTokenFilter)value, null); + break; case "reverse": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ReverseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ReverseTokenFilter)value, null); + break; case "shingle": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ShingleTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ShingleTokenFilter)value, null); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SnowballTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SnowballTokenFilter)value, null); + break; case "stemmer_override": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StemmerOverrideTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StemmerOverrideTokenFilter)value, null); + break; case "stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StemmerTokenFilter)value, null); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StopTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StopTokenFilter)value, null); + break; case "synonym_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SynonymGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SynonymGraphTokenFilter)value, null); + break; case "synonym": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SynonymTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SynonymTokenFilter)value, null); + break; case "trim": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TrimTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TrimTokenFilter)value, null); + break; case "truncate": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TruncateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TruncateTokenFilter)value, null); + break; case "unique": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UniqueTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UniqueTokenFilter)value, null); + break; case "uppercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UppercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UppercaseTokenFilter)value, null); + break; case "word_delimiter_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter)value, null); + break; case "word_delimiter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WordDelimiterTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WordDelimiterTokenFilter)value, null); + 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/_Generated/Types/Analysis/Tokenizers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs index 54f24ae2bab..9b794113254 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs @@ -122,130 +122,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, null)) + { + 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, null), + "classic" => reader.ReadValue(options, null), + "edge_ngram" => reader.ReadValue(options, null), + "icu_tokenizer" => reader.ReadValue(options, null), + "keyword" => reader.ReadValue(options, null), + "kuromoji_tokenizer" => reader.ReadValue(options, null), + "letter" => reader.ReadValue(options, null), + "lowercase" => reader.ReadValue(options, null), + "ngram" => reader.ReadValue(options, null), + "nori_tokenizer" => reader.ReadValue(options, null), + "path_hierarchy" => reader.ReadValue(options, null), + "pattern" => reader.ReadValue(options, null), + "simple_pattern_split" => reader.ReadValue(options, null), + "simple_pattern" => reader.ReadValue(options, null), + "standard" => reader.ReadValue(options, null), + "thai" => reader.ReadValue(options, null), + "uax_url_email" => reader.ReadValue(options, null), + "whitespace" => reader.ReadValue(options, null), + _ => 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.Analysis.CharGroupTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CharGroupTokenizer)value, null); + break; case "classic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ClassicTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ClassicTokenizer)value, null); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenizer)value, null); + break; case "icu_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuTokenizer)value, null); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordTokenizer)value, null); + break; case "kuromoji_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiTokenizer)value, null); + break; case "letter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LetterTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LetterTokenizer)value, null); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenizer)value, null); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NGramTokenizer)value, null); + break; case "nori_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriTokenizer)value, null); + break; case "path_hierarchy": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PathHierarchyTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PathHierarchyTokenizer)value, null); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternTokenizer)value, null); + break; case "simple_pattern_split": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimplePatternSplitTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimplePatternSplitTokenizer)value, null); + break; case "simple_pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimplePatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimplePatternTokenizer)value, null); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StandardTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StandardTokenizer)value, null); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ThaiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ThaiTokenizer)value, null); + break; case "uax_url_email": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UaxEmailUrlTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UaxEmailUrlTokenizer)value, null); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WhitespaceTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WhitespaceTokenizer)value, null); + 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/_Generated/Types/Analysis/TurkishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs index 29aad7e4200..dd1daf30aa6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs @@ -27,17 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryReadProperty(ref reader, options, PropStemExclusion, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStopwords.TryReadProperty(ref reader, options, PropStopwords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propStopwordsPath.TryReadProperty(ref reader, options, PropStopwordsPath, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/AsyncSearch/AsyncSearch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs index bcaf721928d..0eb57339d3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs @@ -27,6 +27,192 @@ namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class AsyncSearchConverter : 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 AsyncSearch Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHitsMetadata.TryReadProperty(ref reader, options, PropHitsMetadata, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AsyncSearch + { + 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, AsyncSearch value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteEndObject(); + } +} + +internal sealed partial class AsyncSearchConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(AsyncSearch<>); + } + + 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(AsyncSearchConverter<>).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(AsyncSearchConverterFactory))] public sealed partial class AsyncSearch { /// @@ -34,15 +220,10 @@ public sealed partial class AsyncSearch /// Partial aggregations results, coming from the shards that have already completed the execution of the query. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } /// @@ -51,13 +232,9 @@ public sealed partial class AsyncSearch /// If this number increases compared to the last retrieved results for a get asynch search request, you can expect additional results included in the search response. /// /// - [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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } /// @@ -66,14 +243,9 @@ public sealed partial class AsyncSearch /// Note that in order for shard results to be included in the search response, they need to be reduced first. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/ByteSize.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ByteSize.g.cs index ff080b07f17..5f4f5a67305 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ByteSize.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ByteSize.g.cs @@ -33,13 +33,52 @@ namespace Elastic.Clients.Elasticsearch; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(ByteSizeConverter))] public sealed partial class ByteSize : Union { - public ByteSize(long Bytesize) : base(Bytesize) + public ByteSize(long bytesize) : base(bytesize) { } - public ByteSize(string Bytesize) : base(Bytesize) + public ByteSize(string bytesize) : base(bytesize) { } + + public static implicit operator ByteSize(long bytesize) => new ByteSize(bytesize); + public static implicit operator ByteSize(string bytesize) => new ByteSize(bytesize); +} + +internal sealed partial class ByteSizeConverter : System.Text.Json.Serialization.JsonConverter +{ + public override ByteSize Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new ByteSize(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new ByteSize(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(ByteSize)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ByteSize value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs index 62b3163daa1..492f855571b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.IndexManagement.IndexSettings))] public IReadOnlyDictionary? Settings { get; init; } [JsonInclude, JsonPropertyName("version")] public long? Version { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs index 00c49f9380c..c2fe4eb7f3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch; public sealed partial class CompletionStats { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.FieldSizeUsage))] public IReadOnlyDictionary? Fields { get; init; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Context.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Context.g.cs index 3b0b5da0aaf..75f9237f0b3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Context.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Context.g.cs @@ -36,13 +36,52 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(ContextConverter))] public sealed partial class Context : Union { - public Context(string Category) : base(Category) + public Context(string category) : base(category) { } - public Context(Elastic.Clients.Elasticsearch.GeoLocation Location) : base(Location) + public Context(Elastic.Clients.Elasticsearch.GeoLocation location) : base(location) { } + + public static implicit operator Context(string category) => new Context(category); + public static implicit operator Context(Elastic.Clients.Elasticsearch.GeoLocation location) => new Context(location); +} + +internal sealed partial class ContextConverter : System.Text.Json.Serialization.JsonConverter +{ + public override Context Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT1(ref r, o, "dummy"); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new Context(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new Context(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(Context)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Context value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs index 7305368830a..f8f9dfc4a37 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs @@ -27,6 +27,155 @@ namespace Elastic.Clients.Elasticsearch.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 PropMetricConflictsIndices = System.Text.Json.JsonEncodedText.Encode("metric_conflicts_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonAggregatableIndices = System.Text.Json.JsonEncodedText.Encode("non_aggregatable_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonDimensionIndices = System.Text.Json.JsonEncodedText.Encode("non_dimension_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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 FieldCapability Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregatable = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propMetadataField = default; + LocalJsonValue?> propMetricConflictsIndices = default; + LocalJsonValue?> propNonAggregatableIndices = default; + LocalJsonValue?> propNonDimensionIndices = default; + LocalJsonValue?> propNonSearchableIndices = default; + LocalJsonValue propSearchable = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregatable.TryReadProperty(ref reader, options, PropAggregatable, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propMetadataField.TryReadProperty(ref reader, options, PropMetadataField, null)) + { + continue; + } + + if (propMetricConflictsIndices.TryReadProperty(ref reader, options, PropMetricConflictsIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNonAggregatableIndices.TryReadProperty(ref reader, options, PropNonAggregatableIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propNonDimensionIndices.TryReadProperty(ref reader, options, PropNonDimensionIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNonSearchableIndices.TryReadProperty(ref reader, options, PropNonSearchableIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propSearchable.TryReadProperty(ref reader, options, PropSearchable, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + MetricConflictsIndices = propMetricConflictsIndices.Value +, + NonAggregatableIndices = propNonAggregatableIndices.Value +, + NonDimensionIndices = propNonDimensionIndices.Value +, + NonSearchableIndices = propNonSearchableIndices.Value +, + Searchable = propSearchable.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropMetadataField, value.MetadataField, null, null); + writer.WriteProperty(options, PropMetricConflictsIndices, value.MetricConflictsIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNonAggregatableIndices, value.NonAggregatableIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNonDimensionIndices, value.NonDimensionIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNonSearchableIndices, value.NonSearchableIndices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSearchable, value.Searchable, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCapabilityConverter))] public sealed partial class FieldCapability { /// @@ -34,7 +183,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 +190,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 +197,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 +204,6 @@ public sealed partial class FieldCapability /// Whether this field is registered as a metadata field. /// /// - [JsonInclude, JsonPropertyName("metadata_field")] public bool? MetadataField { get; init; } /// @@ -68,7 +212,6 @@ public sealed partial class FieldCapability /// don’t have the same time_series_metric value for this field. /// /// - [JsonInclude, JsonPropertyName("metric_conflicts_indices")] public IReadOnlyCollection? MetricConflictsIndices { get; init; } /// @@ -76,8 +219,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; } /// @@ -86,7 +227,6 @@ public sealed partial class FieldCapability /// field marked as a dimension and other indices, the ones in this list, do not. /// /// - [JsonInclude, JsonPropertyName("non_dimension_indices")] public IReadOnlyCollection? NonDimensionIndices { get; init; } /// @@ -94,8 +234,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; } /// @@ -103,7 +241,6 @@ public sealed partial class FieldCapability /// Whether this field is indexed for search on all indices. /// /// - [JsonInclude, JsonPropertyName("searchable")] public bool Searchable { get; init; } /// @@ -111,7 +248,6 @@ public sealed partial class FieldCapability /// Whether this field is used as a time series dimension. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; init; } /// @@ -120,8 +256,6 @@ public sealed partial class FieldCapability /// metrics, absent if the field is not used as metric. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs index 07624ca28ed..0242d7acc14 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs @@ -27,27 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIgnored.TryReadProperty(ref reader, options, PropIgnored, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFound, value.Found, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIgnored, value.Ignored, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.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/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs index 389fd578f42..ed98e48d43b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs @@ -27,17 +27,90 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propFeatureStates = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propSlmPolicies = default; + LocalJsonValue?> propSnapshotRepositories = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureStates.TryReadProperty(ref reader, options, PropFeatureStates, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propNodes.TryReadProperty(ref reader, options, PropNodes, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSlmPolicies.TryReadProperty(ref reader, options, PropSlmPolicies, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSnapshotRepositories.TryReadProperty(ref reader, options, PropSnapshotRepositories, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNodes, value.Nodes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSlmPolicies, value.SlmPolicies, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSnapshotRepositories, value.SnapshotRepositories, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Types/Core/MGet/MultiGetOperation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs index eb20a84fc6e..3fadb68efd9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs @@ -27,6 +27,105 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (propVersionType.TryReadProperty(ref reader, options, PropVersionType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteProperty(options, PropVersionType, value.VersionType, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiGetOperationConverter))] public sealed partial class MultiGetOperation { /// @@ -34,7 +133,6 @@ public sealed partial class MultiGetOperation /// The unique document ID. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Id Id { get; set; } /// @@ -42,7 +140,6 @@ public sealed partial class MultiGetOperation /// The index that contains the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -50,7 +147,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.Routing? Routing { get; set; } /// @@ -58,7 +154,6 @@ public sealed partial class MultiGetOperation /// If false, excludes all _source fields. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -66,12 +161,8 @@ public sealed partial class MultiGetOperation /// The stored fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs index 48bf0448faf..fe3161538f8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs @@ -27,36 +27,217 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; +internal sealed partial class MultiSearchItemConverter : 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 PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + 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 MultiSearchItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue propStatus = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, null)) + { + continue; + } + + if (propClusters.TryReadProperty(ref reader, options, PropClusters, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHitsMetadata.TryReadProperty(ref reader, options, PropHitsMetadata, null)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propNumReducePhases.TryReadProperty(ref reader, options, PropNumReducePhases, null)) + { + continue; + } + + if (propPitId.TryReadProperty(ref reader, options, PropPitId, null)) + { + continue; + } + + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } + + if (propScrollId.TryReadProperty(ref reader, options, PropScrollId, null)) + { + continue; + } + + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) + { + continue; + } + + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } + + if (propTerminatedEarly.TryReadProperty(ref reader, options, PropTerminatedEarly, null)) + { + continue; + } + + if (propTimedOut.TryReadProperty(ref reader, options, PropTimedOut, null)) + { + continue; + } + + if (propTook.TryReadProperty(ref reader, options, PropTook, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchItem + { + 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 +, + Status = propStatus.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations, null, null); + writer.WriteProperty(options, PropClusters, value.Clusters, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata, null, null); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases, null, null); + writer.WriteProperty(options, PropPitId, value.PitId, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropScrollId, value.ScrollId, null, null); + writer.WriteProperty(options, PropShards, value.Shards, null, null); + writer.WriteProperty(options, PropStatus, value.Status, null, null); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly, null, null); + writer.WriteProperty(options, PropTimedOut, value.TimedOut, null, null); + writer.WriteProperty(options, PropTook, value.Took, null, null); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchItemConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchItem<>); + } + + 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(MultiSearchItemConverter<>).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(MultiSearchItemConverterFactory))] public sealed partial class MultiSearchItem { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.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.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("status")] public int? Status { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index 1cac0049899..0984897e621 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -27,399 +27,341 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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 (propCollapse.TryReadProperty(ref reader, options, PropCollapse, null)) + { + continue; + } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propDocvalueFields.TryReadProperty(ref reader, options, PropDocvalueFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExt.TryReadProperty(ref reader, options, PropExt, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propFields.TryReadProperty(ref reader, options, PropFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndicesBoost.TryReadProperty(ref reader, options, PropIndicesBoost, static ICollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, static IDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!))) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propKnn.TryReadProperty(ref reader, options, PropKnn, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propPit.TryReadProperty(ref reader, options, PropPit, null)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPostFilter.TryReadProperty(ref reader, options, PropPostFilter, null)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propProfile.TryReadProperty(ref reader, options, PropProfile, null)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRescore.TryReadProperty(ref reader, options, PropRescore, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propSearchAfter.TryReadProperty(ref reader, options, PropSearchAfter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSeqNoPrimaryTerm.TryReadProperty(ref reader, options, PropSeqNoPrimaryTerm, null)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propStats.TryReadProperty(ref reader, options, PropStats, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propSuggest.TryReadProperty(ref reader, options, PropSuggest, null)) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propTerminateAfter.TryReadProperty(ref reader, options, PropTerminateAfter, null)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTimeout.TryReadProperty(ref reader, options, PropTimeout, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTrackScores.TryReadProperty(ref reader, options, PropTrackScores, null)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackTotalHits.TryReadProperty(ref reader, options, PropTrackTotalHits, null)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropCollapse, value.Collapse, null, null); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropExt, value.Ext, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection>? v) => w.WriteCollectionValue>(o, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary v) => w.WriteDictionaryValue(o, v, null, null))); + writer.WriteProperty(options, PropKnn, value.Knn, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropPit, value.Pit, null, null); + writer.WriteProperty(options, PropPostFilter, value.PostFilter, null, null); + writer.WriteProperty(options, PropProfile, value.Profile, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropRescore, value.Rescore, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStats, value.Stats, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropSuggest, value.Suggest, null, null); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter, null, null); + writer.WriteProperty(options, PropTimeout, value.Timeout, null, null); + writer.WriteProperty(options, PropTrackScores, value.TrackScores, null, null); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs index c9ff671b68d..511eb8dd690 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs @@ -27,35 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowNoIndices = default; + LocalJsonValue propAllowPartialSearchResults = default; + LocalJsonValue propCcsMinimizeRoundtrips = default; + LocalJsonValue?> propExpandWildcards = default; + LocalJsonValue propIgnoreThrottled = default; + LocalJsonValue propIgnoreUnavailable = default; + LocalJsonValue propIndices = default; + LocalJsonValue propPreference = default; + LocalJsonValue propRequestCache = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSearchType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryReadProperty(ref reader, options, PropAllowNoIndices, null)) + { + continue; + } + + if (propAllowPartialSearchResults.TryReadProperty(ref reader, options, PropAllowPartialSearchResults, null)) + { + continue; + } + + if (propCcsMinimizeRoundtrips.TryReadProperty(ref reader, options, PropCcsMinimizeRoundtrips, null)) + { + continue; + } + + if (propExpandWildcards.TryReadProperty(ref reader, options, PropExpandWildcards, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propIgnoreThrottled.TryReadProperty(ref reader, options, PropIgnoreThrottled, null)) + { + continue; + } + + if (propIgnoreUnavailable.TryReadProperty(ref reader, options, PropIgnoreUnavailable, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propPreference.TryReadProperty(ref reader, options, PropPreference, null)) + { + continue; + } + + if (propRequestCache.TryReadProperty(ref reader, options, PropRequestCache, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSearchType.TryReadProperty(ref reader, options, PropSearchType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAllowPartialSearchResults, value.AllowPartialSearchResults, null, null); + writer.WriteProperty(options, PropCcsMinimizeRoundtrips, value.CcsMinimizeRoundtrips, null, null); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled, null, null); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropPreference, value.Preference, null, null); + writer.WriteProperty(options, PropRequestCache, value.RequestCache, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSearchType, value.SearchType, null, null); + 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.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.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.Routing? Routing { get; set; } - [JsonInclude, JsonPropertyName("search_type")] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs index a21f16a7f7d..ecd728bbeac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs @@ -27,6 +27,165 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDoc = default; + LocalJsonValue propFields = default; + LocalJsonValue propFieldStatistics = default; + LocalJsonValue propFilter = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propOffsets = default; + LocalJsonValue propPayloads = default; + LocalJsonValue propPositions = default; + LocalJsonValue propRouting = default; + LocalJsonValue propTermStatistics = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryReadProperty(ref reader, options, PropDoc, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propFieldStatistics.TryReadProperty(ref reader, options, PropFieldStatistics, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, null)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propOffsets.TryReadProperty(ref reader, options, PropOffsets, null)) + { + continue; + } + + if (propPayloads.TryReadProperty(ref reader, options, PropPayloads, null)) + { + continue; + } + + if (propPositions.TryReadProperty(ref reader, options, PropPositions, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propTermStatistics.TryReadProperty(ref reader, options, PropTermStatistics, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (propVersionType.TryReadProperty(ref reader, options, PropVersionType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropFieldStatistics, value.FieldStatistics, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, null); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropOffsets, value.Offsets, null, null); + writer.WriteProperty(options, PropPayloads, value.Payloads, null, null); + writer.WriteProperty(options, PropPositions, value.Positions, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropTermStatistics, value.TermStatistics, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteProperty(options, PropVersionType, value.VersionType, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermVectorsOperationConverter))] public sealed partial class MultiTermVectorsOperation { /// @@ -34,7 +193,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 +201,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.Fields? Fields { get; set; } /// @@ -52,7 +208,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 +215,6 @@ public sealed partial class MultiTermVectorsOperation /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Core.TermVectors.Filter? Filter { get; set; } /// @@ -68,7 +222,6 @@ public sealed partial class MultiTermVectorsOperation /// The ID of the document. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Id? Id { get; set; } /// @@ -76,7 +229,6 @@ public sealed partial class MultiTermVectorsOperation /// The index of the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -84,7 +236,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term offsets. /// /// - [JsonInclude, JsonPropertyName("offsets")] public bool? Offsets { get; set; } /// @@ -92,7 +243,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term payloads. /// /// - [JsonInclude, JsonPropertyName("payloads")] public bool? Payloads { get; set; } /// @@ -100,7 +250,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term positions. /// /// - [JsonInclude, JsonPropertyName("positions")] public bool? Positions { get; set; } /// @@ -108,7 +257,6 @@ public sealed partial class MultiTermVectorsOperation /// Custom value used to route operations to a specific shard. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -116,7 +264,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 +271,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 +278,6 @@ public sealed partial class MultiTermVectorsOperation /// Specific version type. /// /// - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs index e8ec6d5f061..3fb09185679 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.Core.TermVectors.TermVector))] public IReadOnlyDictionary? TermVectors { get; init; } [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiGetResponseItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiGetResponseItem.g.cs index 3db3670ab7e..1f6846a8a6b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiGetResponseItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiGetResponseItem.g.cs @@ -30,13 +30,69 @@ namespace Elastic.Clients.Elasticsearch.Core.MGet; +[JsonConverter(typeof(MultiGetResponseItemConverterFactory))] public sealed partial class MultiGetResponseItem : Union, Elastic.Clients.Elasticsearch.Core.MGet.MultiGetError> { - public MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.Get.GetResult Result) : base(Result) + public MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.Get.GetResult result) : base(result) { } - public MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.MGet.MultiGetError Failure) : base(Failure) + public MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.MGet.MultiGetError failure) : base(failure) { } + + public static implicit operator MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.Get.GetResult result) => new MultiGetResponseItem(result); + public static implicit operator MultiGetResponseItem(Elastic.Clients.Elasticsearch.Core.MGet.MultiGetError failure) => new MultiGetResponseItem(failure); +} + +internal sealed partial class MultiGetResponseItemConverter : System.Text.Json.Serialization.JsonConverter> +{ + public override MultiGetResponseItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT1(ref r, o, "found"); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new MultiGetResponseItem(reader.ReadValue>(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new MultiGetResponseItem(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(MultiGetResponseItem)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiGetResponseItem value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } +} + +internal sealed partial class MultiGetResponseItemConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiGetResponseItem<>); + } + + 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(MultiGetResponseItemConverter<>).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/_Generated/Types/Core/MultiSearchResponseItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiSearchResponseItem.g.cs index e4d5c8f2dcb..8789586fc01 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiSearchResponseItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MultiSearchResponseItem.g.cs @@ -30,13 +30,69 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; +[JsonConverter(typeof(MultiSearchResponseItemConverterFactory))] public sealed partial class MultiSearchResponseItem : Union, Elastic.Clients.Elasticsearch.ErrorResponseBase> { - public MultiSearchResponseItem(Elastic.Clients.Elasticsearch.Core.MSearch.MultiSearchItem Result) : base(Result) + public MultiSearchResponseItem(Elastic.Clients.Elasticsearch.Core.MSearch.MultiSearchItem result) : base(result) { } - public MultiSearchResponseItem(Elastic.Clients.Elasticsearch.ErrorResponseBase Failure) : base(Failure) + public MultiSearchResponseItem(Elastic.Clients.Elasticsearch.ErrorResponseBase failure) : base(failure) { } + + public static implicit operator MultiSearchResponseItem(Elastic.Clients.Elasticsearch.Core.MSearch.MultiSearchItem result) => new MultiSearchResponseItem(result); + public static implicit operator MultiSearchResponseItem(Elastic.Clients.Elasticsearch.ErrorResponseBase failure) => new MultiSearchResponseItem(failure); +} + +internal sealed partial class MultiSearchResponseItemConverter : System.Text.Json.Serialization.JsonConverter> +{ + public override MultiSearchResponseItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT1(ref r, o, "took"); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new MultiSearchResponseItem(reader.ReadValue>(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new MultiSearchResponseItem(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(MultiSearchResponseItem)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchResponseItem value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } +} + +internal sealed partial class MultiSearchResponseItemConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchResponseItem<>); + } + + 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(MultiSearchResponseItemConverter<>).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/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs index 687bd0ffd08..4361b86a55f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs @@ -27,11 +27,63 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options, null); + 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, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalQueryConverter))] public sealed partial class RankEvalQuery { - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query Query { get; set; } - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs index 0c75aa06abf..582aaa110bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propIndices = default; + LocalJsonValue propQuery = default; + LocalJsonValue propRemote = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propRemote.TryReadProperty(ref reader, options, PropRemote, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSlice.TryReadProperty(ref reader, options, PropSlice, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propSourceFields.TryReadProperty(ref reader, options, PropSourceFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropRemote, value.Remote, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSlice, value.Slice, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SourceConverter))] public sealed partial class Source { /// @@ -35,7 +144,6 @@ public sealed partial class Source /// Accepts a comma-separated list to reindex from multiple sources. /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Indices Indices { get; set; } /// @@ -43,7 +151,6 @@ public sealed partial class Source /// Specifies the documents to reindex using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -51,9 +158,7 @@ public sealed partial class Source /// A remote instance of Elasticsearch that you want to index from. /// /// - [JsonInclude, JsonPropertyName("remote")] public Elastic.Clients.Elasticsearch.Core.Reindex.RemoteSource? Remote { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -62,7 +167,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 +174,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.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -82,8 +183,6 @@ public sealed partial class Source /// Set to a list to reindex select fields. /// /// - [JsonInclude, JsonPropertyName("_source")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? SourceFields { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/ReindexRethrottle/ReindexTask.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/ReindexRethrottle/ReindexTask.g.cs index c2c8d0e3a6f..c6a43b3b00d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/ReindexRethrottle/ReindexTask.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/ReindexRethrottle/ReindexTask.g.cs @@ -27,26 +27,145 @@ namespace Elastic.Clients.Elasticsearch.Core.ReindexRethrottle; +internal sealed partial class ReindexTaskConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAction = System.Text.Json.JsonEncodedText.Encode("action"); + private static readonly System.Text.Json.JsonEncodedText PropCancellable = System.Text.Json.JsonEncodedText.Encode("cancellable"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropHeaders = System.Text.Json.JsonEncodedText.Encode("headers"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropRunningTimeInNanos = System.Text.Json.JsonEncodedText.Encode("running_time_in_nanos"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ReindexTask Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAction = default; + LocalJsonValue propCancellable = default; + LocalJsonValue propDescription = default; + LocalJsonValue>>> propHeaders = default; + LocalJsonValue propId = default; + LocalJsonValue propNode = default; + LocalJsonValue propRunningTimeInNanos = default; + LocalJsonValue propStartTimeInMillis = default; + LocalJsonValue propStatus = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAction.TryReadProperty(ref reader, options, PropAction, null)) + { + continue; + } + + if (propCancellable.TryReadProperty(ref reader, options, PropCancellable, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propHeaders.TryReadProperty(ref reader, options, PropHeaders, static IReadOnlyDictionary>> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!)!)) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propNode.TryReadProperty(ref reader, options, PropNode, null)) + { + continue; + } + + if (propRunningTimeInNanos.TryReadProperty(ref reader, options, PropRunningTimeInNanos, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReindexTask + { + Action = propAction.Value +, + Cancellable = propCancellable.Value +, + Description = propDescription.Value +, + Headers = propHeaders.Value +, + Id = propId.Value +, + Node = propNode.Value +, + RunningTimeInNanos = propRunningTimeInNanos.Value +, + StartTimeInMillis = propStartTimeInMillis.Value +, + Status = propStatus.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReindexTask value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAction, value.Action, null, null); + writer.WriteProperty(options, PropCancellable, value.Cancellable, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropHeaders, value.Headers, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>> v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropNode, value.Node, null, null); + writer.WriteProperty(options, PropRunningTimeInNanos, value.RunningTimeInNanos, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + writer.WriteProperty(options, PropStatus, value.Status, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReindexTaskConverter))] public sealed partial class ReindexTask { - [JsonInclude, JsonPropertyName("action")] public string Action { get; init; } - [JsonInclude, JsonPropertyName("cancellable")] public bool Cancellable { get; init; } - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("headers")] public IReadOnlyDictionary>> Headers { get; init; } - [JsonInclude, JsonPropertyName("id")] public long Id { get; init; } - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } - [JsonInclude, JsonPropertyName("running_time_in_nanos")] public long RunningTimeInNanos { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Core.ReindexRethrottle.ReindexStatus Status { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs index 7e8b2f44500..4ba25cbaae6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs @@ -27,6 +27,90 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propContext = default; + LocalJsonValue?> propNeighbours = default; + LocalJsonValue propPrecision = default; + LocalJsonValue propPrefix = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propContext.TryReadProperty(ref reader, options, PropContext, null)) + { + continue; + } + + if (propNeighbours.TryReadProperty(ref reader, options, PropNeighbours, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propPrecision.TryReadProperty(ref reader, options, PropPrecision, null)) + { + continue; + } + + if (propPrefix.TryReadProperty(ref reader, options, PropPrefix, null)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options, null); + 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, null, null); + writer.WriteProperty(options, PropContext, value.Context, null, null); + writer.WriteProperty(options, PropNeighbours, value.Neighbours, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPrecision, value.Precision, null, null); + writer.WriteProperty(options, PropPrefix, value.Prefix, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionContextConverter))] public sealed partial class CompletionContext { /// @@ -35,7 +119,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 +126,6 @@ public sealed partial class CompletionContext /// The value of the category to filter/boost on. /// /// - [JsonInclude, JsonPropertyName("context")] public Elastic.Clients.Elasticsearch.Core.Search.Context Context { get; set; } /// @@ -53,7 +135,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 +144,6 @@ public sealed partial class CompletionContext /// Defaults to index time precision level. /// /// - [JsonInclude, JsonPropertyName("precision")] public Elastic.Clients.Elasticsearch.GeohashPrecision? Precision { get; set; } /// @@ -71,7 +151,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/_Generated/Types/Core/Search/CompletionSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs index c294fa934bc..68b29071904 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs @@ -27,15 +27,98 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue>> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryReadProperty(ref reader, options, PropLength, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOptions.TryReadProperty(ref reader, options, PropOptions, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue>(o, null)!)) + { + continue; + } + + if (propText.TryReadProperty(ref reader, options, PropText, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOptions, value.Options, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteSingleOrManyCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropText, value.Text, null, null); + 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/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs index 3e0c73771fb..77c91b2f887 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs @@ -27,27 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCollateMatch = default; + LocalJsonValue>?> propContexts = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propRouting = default; + LocalJsonValue propScore = default; + LocalJsonValue propScore0 = default; + LocalJsonValue propSource = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollateMatch.TryReadProperty(ref reader, options, PropCollateMatch, null)) + { + continue; + } + + if (propContexts.TryReadProperty(ref reader, options, PropContexts, static IReadOnlyDictionary>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!))) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propScore.TryReadProperty(ref reader, options, PropScore, null)) + { + continue; + } + + if (propScore0.TryReadProperty(ref reader, options, PropScore0, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propText.TryReadProperty(ref reader, options, PropText, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropContexts, value.Contexts, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>? v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropScore, value.Score, null, null); + writer.WriteProperty(options, PropScore0, value.Score0, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropText, value.Text, null, null); + 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/_Generated/Types/Core/Search/CompletionSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggester.g.cs index 29e84a56d33..1f88250286e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggester.g.cs @@ -27,6 +27,105 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class CompletionSuggesterConverter : 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 PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText PropRegex = System.Text.Json.JsonEncodedText.Encode("regex"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSkipDuplicates = System.Text.Json.JsonEncodedText.Encode("skip_duplicates"); + + public override CompletionSuggester Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue>>?> propContexts = default; + LocalJsonValue propField = default; + LocalJsonValue propFuzzy = default; + LocalJsonValue propRegex = default; + LocalJsonValue propSize = default; + LocalJsonValue propSkipDuplicates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propContexts.TryReadProperty(ref reader, options, PropContexts, static IDictionary>>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT1(ref r, o, "dummy"), null, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!))) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFuzzy.TryReadProperty(ref reader, options, PropFuzzy, null)) + { + continue; + } + + if (propRegex.TryReadProperty(ref reader, options, PropRegex, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSkipDuplicates.TryReadProperty(ref reader, options, PropSkipDuplicates, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionSuggester + { + Analyzer = propAnalyzer.Value +, + Contexts = propContexts.Value +, + Field = propField.Value +, + Fuzzy = propFuzzy.Value +, + Regex = propRegex.Value +, + Size = propSize.Value +, + SkipDuplicates = propSkipDuplicates.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionSuggester value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer, null, null); + writer.WriteProperty(options, PropContexts, value.Contexts, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary>>? v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFuzzy, value.Fuzzy, null, null); + writer.WriteProperty(options, PropRegex, value.Regex, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSkipDuplicates, value.SkipDuplicates, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionSuggesterConverter))] public sealed partial class CompletionSuggester { /// @@ -35,7 +134,6 @@ public sealed partial class CompletionSuggester /// Defaults to the search analyzer of the suggest field. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -43,7 +141,6 @@ public sealed partial class CompletionSuggester /// A value, geo point object, or a geo hash string to filter or boost the suggestion on. /// /// - [JsonInclude, JsonPropertyName("contexts")] public IDictionary>>? Contexts { get; set; } /// @@ -52,7 +149,6 @@ public sealed partial class CompletionSuggester /// Needs to be set globally or per suggestion. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -60,7 +156,6 @@ public sealed partial class CompletionSuggester /// Enables fuzziness, meaning you can have a typo in your search and still get results back. /// /// - [JsonInclude, JsonPropertyName("fuzzy")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestFuzziness? Fuzzy { get; set; } /// @@ -68,7 +163,6 @@ public sealed partial class CompletionSuggester /// A regex query that expresses a prefix as a regular expression. /// /// - [JsonInclude, JsonPropertyName("regex")] public Elastic.Clients.Elasticsearch.Core.Search.RegexOptions? Regex { get; set; } /// @@ -76,7 +170,6 @@ public sealed partial class CompletionSuggester /// The maximum corrections to be returned per suggest text token. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -84,7 +177,6 @@ public sealed partial class CompletionSuggester /// Whether duplicate suggestions should be filtered out. /// /// - [JsonInclude, JsonPropertyName("skip_duplicates")] public bool? SkipDuplicates { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Core.Search.FieldSuggester(CompletionSuggester completionSuggester) => Elastic.Clients.Elasticsearch.Core.Search.FieldSuggester.Completion(completionSuggester); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs index 06fbcd812b5..ec25b4de388 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs @@ -27,9 +27,77 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCollapse = default; + LocalJsonValue propField = default; + LocalJsonValue?> propInnerHits = default; + LocalJsonValue propMaxConcurrentGroupSearches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryReadProperty(ref reader, options, PropCollapse, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propInnerHits.TryReadProperty(ref reader, options, PropInnerHits, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMaxConcurrentGroupSearches.TryReadProperty(ref reader, options, PropMaxConcurrentGroupSearches, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropInnerHits, value.InnerHits, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMaxConcurrentGroupSearches, value.MaxConcurrentGroupSearches, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCollapseConverter))] public sealed partial class FieldCollapse { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -37,7 +105,6 @@ public sealed partial class FieldCollapse /// The field to collapse the result set on /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -45,8 +112,6 @@ public sealed partial class FieldCollapse /// The number of inner hits and their sort order /// /// - [JsonInclude, JsonPropertyName("inner_hits")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.InnerHits))] public ICollection? InnerHits { get; set; } /// @@ -54,7 +119,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/_Generated/Types/Core/Search/FieldSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs index eb342fd32f5..a083dae491e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs @@ -39,12 +39,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.Core.Search.CompletionSuggester completionSuggester) => new FieldSuggester("completion", completionSuggester); public static FieldSuggester Phrase(Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester phraseSuggester) => new FieldSuggester("phrase", phraseSuggester); @@ -88,121 +92,108 @@ 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); + LocalJsonValue propPrefix = default; + LocalJsonValue propRegex = default; + LocalJsonValue 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) + if (propPrefix.TryReadProperty(ref reader, options, PropPrefix, null)) { - 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 == "prefix") + if (propRegex.TryReadProperty(ref reader, options, PropRegex, null)) { - prefixValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "regex") + if (propText.TryReadProperty(ref reader, options, PropText, null)) { - regexValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "text") + if (reader.ValueTextEquals(VariantCompletion)) { - textValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantCompletion.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "completion") + if (reader.ValueTextEquals(VariantPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "phrase") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "term") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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)) - { - writer.WritePropertyName("prefix"); - writer.WriteStringValue(value.Prefix); - } - - if (!string.IsNullOrEmpty(value.Regex)) - { - writer.WritePropertyName("regex"); - writer.WriteStringValue(value.Regex); - } - - if (!string.IsNullOrEmpty(value.Text)) + switch (value.VariantType) { - 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.Core.Search.CompletionSuggester)value.Variant, options); - break; - case "phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.TermSuggester)value.Variant, options); - break; - } + case "": + break; + case "completion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggester?)value.Variant, null, null); + break; + case "phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester?)value.Variant, null, null); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.TermSuggester?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FieldSuggester)}'."); } + writer.WriteProperty(options, PropPrefix, value.Prefix, null, null); + writer.WriteProperty(options, PropRegex, value.Regex, null, null); + writer.WriteProperty(options, PropText, value.Text, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs index ef12eaa8957..6734533e17e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs @@ -27,6 +27,255 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoundaryChars = default; + LocalJsonValue propBoundaryMaxScan = default; + LocalJsonValue propBoundaryScanner = default; + LocalJsonValue propBoundaryScannerLocale = default; + LocalJsonValue propFragmenter = default; + LocalJsonValue propFragmentOffset = default; + LocalJsonValue propFragmentSize = default; + LocalJsonValue propHighlightFilter = default; + LocalJsonValue propHighlightQuery = default; + LocalJsonValue propMatchedFields = default; + LocalJsonValue propMaxAnalyzedOffset = default; + LocalJsonValue propMaxFragmentLength = default; + LocalJsonValue propNoMatchSize = default; + LocalJsonValue propNumberOfFragments = default; + LocalJsonValue?> propOptions = default; + LocalJsonValue propOrder = default; + LocalJsonValue propPhraseLimit = default; + LocalJsonValue?> propPostTags = default; + LocalJsonValue?> propPreTags = default; + LocalJsonValue propRequireFieldMatch = default; + LocalJsonValue propTagsSchema = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoundaryChars.TryReadProperty(ref reader, options, PropBoundaryChars, null)) + { + continue; + } + + if (propBoundaryMaxScan.TryReadProperty(ref reader, options, PropBoundaryMaxScan, null)) + { + continue; + } + + if (propBoundaryScanner.TryReadProperty(ref reader, options, PropBoundaryScanner, null)) + { + continue; + } + + if (propBoundaryScannerLocale.TryReadProperty(ref reader, options, PropBoundaryScannerLocale, null)) + { + continue; + } + + if (propFragmenter.TryReadProperty(ref reader, options, PropFragmenter, null)) + { + continue; + } + + if (propFragmentOffset.TryReadProperty(ref reader, options, PropFragmentOffset, null)) + { + continue; + } + + if (propFragmentSize.TryReadProperty(ref reader, options, PropFragmentSize, null)) + { + continue; + } + + if (propHighlightFilter.TryReadProperty(ref reader, options, PropHighlightFilter, null)) + { + continue; + } + + if (propHighlightQuery.TryReadProperty(ref reader, options, PropHighlightQuery, null)) + { + continue; + } + + if (propMatchedFields.TryReadProperty(ref reader, options, PropMatchedFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propMaxAnalyzedOffset.TryReadProperty(ref reader, options, PropMaxAnalyzedOffset, null)) + { + continue; + } + + if (propMaxFragmentLength.TryReadProperty(ref reader, options, PropMaxFragmentLength, null)) + { + continue; + } + + if (propNoMatchSize.TryReadProperty(ref reader, options, PropNoMatchSize, null)) + { + continue; + } + + if (propNumberOfFragments.TryReadProperty(ref reader, options, PropNumberOfFragments, null)) + { + continue; + } + + if (propOptions.TryReadProperty(ref reader, options, PropOptions, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, null)) + { + continue; + } + + if (propPhraseLimit.TryReadProperty(ref reader, options, PropPhraseLimit, null)) + { + continue; + } + + if (propPostTags.TryReadProperty(ref reader, options, PropPostTags, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propPreTags.TryReadProperty(ref reader, options, PropPreTags, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propRequireFieldMatch.TryReadProperty(ref reader, options, PropRequireFieldMatch, null)) + { + continue; + } + + if (propTagsSchema.TryReadProperty(ref reader, options, PropTagsSchema, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoundaryMaxScan, value.BoundaryMaxScan, null, null); + writer.WriteProperty(options, PropBoundaryScanner, value.BoundaryScanner, null, null); + writer.WriteProperty(options, PropBoundaryScannerLocale, value.BoundaryScannerLocale, null, null); + writer.WriteProperty(options, PropFragmenter, value.Fragmenter, null, null); + writer.WriteProperty(options, PropFragmentOffset, value.FragmentOffset, null, null); + writer.WriteProperty(options, PropFragmentSize, value.FragmentSize, null, null); + writer.WriteProperty(options, PropHighlightFilter, value.HighlightFilter, null, null); + writer.WriteProperty(options, PropHighlightQuery, value.HighlightQuery, null, null); + writer.WriteProperty(options, PropMatchedFields, value.MatchedFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropMaxAnalyzedOffset, value.MaxAnalyzedOffset, null, null); + writer.WriteProperty(options, PropMaxFragmentLength, value.MaxFragmentLength, null, null); + writer.WriteProperty(options, PropNoMatchSize, value.NoMatchSize, null, null); + writer.WriteProperty(options, PropNumberOfFragments, value.NumberOfFragments, null, null); + writer.WriteProperty(options, PropOptions, value.Options, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropOrder, value.Order, null, null); + writer.WriteProperty(options, PropPhraseLimit, value.PhraseLimit, null, null); + writer.WriteProperty(options, PropPostTags, value.PostTags, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPreTags, value.PreTags, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropRequireFieldMatch, value.RequireFieldMatch, null, null); + writer.WriteProperty(options, PropTagsSchema, value.TagsSchema, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HighlightFieldConverter))] public sealed partial class HighlightField { /// @@ -34,7 +283,6 @@ public sealed partial class HighlightField /// A string that contains each boundary character. /// /// - [JsonInclude, JsonPropertyName("boundary_chars")] public string? BoundaryChars { get; set; } /// @@ -42,7 +290,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 +299,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.Core.Search.BoundaryScanner? BoundaryScanner { get; set; } /// @@ -61,7 +307,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 +315,7 @@ public sealed partial class HighlightField /// Only valid for the plain highlighter. /// /// - [JsonInclude, JsonPropertyName("fragmenter")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterFragmenter? Fragmenter { get; set; } - [JsonInclude, JsonPropertyName("fragment_offset")] public int? FragmentOffset { get; set; } /// @@ -80,9 +323,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 +332,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.QueryDsl.Query? HighlightQuery { get; set; } - [JsonInclude, JsonPropertyName("matched_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? MatchedFields { get; set; } /// @@ -104,9 +342,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 +350,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 +361,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 +372,6 @@ public sealed partial class HighlightField /// Each highlighter applies its own logic to compute relevancy scores. /// /// - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterOrder? Order { get; set; } /// @@ -150,7 +382,6 @@ public sealed partial class HighlightField /// Only supported by the fvh highlighter. /// /// - [JsonInclude, JsonPropertyName("phrase_limit")] public int? PhraseLimit { get; set; } /// @@ -159,7 +390,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 +398,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 +406,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 +413,7 @@ public sealed partial class HighlightField /// Set to styled to use the built-in tag schema. /// /// - [JsonInclude, JsonPropertyName("tags_schema")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterTagsSchema? TagsSchema { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterType? Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs index bddd3f292b6..4833d3e6ea3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs @@ -27,47 +27,272 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propExplanation = default; + LocalJsonValue?> propFields = default; + LocalJsonValue>?> propHighlight = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue>?> propIgnoredFieldValues = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propInnerHits = default; + LocalJsonValue?> propMatchedQueries = default; + LocalJsonValue propNested = default; + LocalJsonValue propNode = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRank = default; + LocalJsonValue propRouting = default; + LocalJsonValue propScore = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShard = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryReadProperty(ref reader, options, PropExplanation, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, static IReadOnlyDictionary>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!))) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIgnored.TryReadProperty(ref reader, options, PropIgnored, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIgnoredFieldValues.TryReadProperty(ref reader, options, PropIgnoredFieldValues, static IReadOnlyDictionary>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!))) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propInnerHits.TryReadProperty(ref reader, options, PropInnerHits, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propMatchedQueries.TryReadProperty(ref reader, options, PropMatchedQueries, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propNested.TryReadProperty(ref reader, options, PropNested, null)) + { + continue; + } + + if (propNode.TryReadProperty(ref reader, options, PropNode, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propRank.TryReadProperty(ref reader, options, PropRank, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propScore.TryReadProperty(ref reader, options, PropScore, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propShard.TryReadProperty(ref reader, options, PropShard, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker)))) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>? v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIgnored, value.Ignored, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIgnoredFieldValues, value.IgnoredFieldValues, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>? v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropInnerHits, value.InnerHits, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropMatchedQueries, value.MatchedQueries, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropNested, value.Nested, null, null); + writer.WriteProperty(options, PropNode, value.Node, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropRank, value.Rank, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropScore, value.Score, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropShard, value.Shard, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, typeof(SourceMarker))); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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.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.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/_Generated/Types/Core/Search/HitsMetadata.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs index 78f5579d8de..b6b0cda0692 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs @@ -27,11 +27,85 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class HitsMetadataConverter : 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 PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override HitsMetadata Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propHits = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue?> propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryReadProperty(ref reader, options, PropHits, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!)) + { + continue; + } + + if (propMaxScore.TryReadProperty(ref reader, options, PropMaxScore, null)) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, static Union? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number), null, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsMetadata + { + Hits = propHits.Value +, + MaxScore = propMaxScore.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsMetadata value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropMaxScore, value.MaxScore, null, null); + writer.WriteProperty(options, PropTotal, value.Total, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union? v) => w.WriteUnionValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsMetadataConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsMetadata<>); + } + + 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(HitsMetadataConverter<>).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(HitsMetadataConverterFactory))] public sealed partial class HitsMetadata { - [JsonInclude, JsonPropertyName("hits")] public IReadOnlyCollection> Hits { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } /// @@ -39,6 +113,5 @@ public sealed partial class HitsMetadata /// Total hit count information, present only if track_total_hits wasn't false in the search request. /// /// - [JsonInclude, JsonPropertyName("total")] public Union? Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs index f896031d7d9..fe12bc7a6b3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs @@ -27,16 +27,200 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propName = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryReadProperty(ref reader, options, PropCollapse, null)) + { + continue; + } + + if (propDocvalueFields.TryReadProperty(ref reader, options, PropDocvalueFields, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propExplain.TryReadProperty(ref reader, options, PropExplain, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propFrom.TryReadProperty(ref reader, options, PropFrom, null)) + { + continue; + } + + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } + + if (propIgnoreUnmapped.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryReadProperty(ref reader, options, PropSeqNoPrimaryTerm, null)) + { + continue; + } + + if (propSize.TryReadProperty(ref reader, options, PropSize, null)) + { + continue; + } + + if (propSort.TryReadProperty(ref reader, options, PropSort, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, null)) + { + continue; + } + + if (propStoredFields.TryReadProperty(ref reader, options, PropStoredFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propTrackScores.TryReadProperty(ref reader, options, PropTrackScores, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropExplain, value.Explain, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropFrom, value.From, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm, null, null); + writer.WriteProperty(options, PropSize, value.Size, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSource, value.Source, null, null); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropTrackScores, value.TrackScores, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InnerHitsConverter))] public sealed partial class InnerHits { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.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.Fields? Fields { get; set; } /// @@ -44,11 +228,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.Core.Search.Highlight? Highlight { get; set; } - [JsonInclude, JsonPropertyName("ignore_unmapped")] public bool? IgnoreUnmapped { get; set; } /// @@ -57,11 +238,8 @@ public sealed partial class InnerHits /// Useful when a search request contains multiple inner hits. /// /// - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.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 +247,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 +255,10 @@ public sealed partial class InnerHits /// By default, inner hits are sorted by score. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Core/Search/PhraseSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs index d00e32970ee..e04a71097aa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs @@ -27,15 +27,81 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryReadProperty(ref reader, options, PropLength, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOptions.TryReadProperty(ref reader, options, PropOptions, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propText.TryReadProperty(ref reader, options, PropText, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOptions, value.Options, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropText, value.Text, null, null); + 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.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/_Generated/Types/Core/Search/Rescore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs index 4690dd4d38a..ec54a4aa481 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs @@ -39,12 +39,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.Core.Search.LearningToRank learningToRank) => new Rescore("learning_to_rank", learningToRank); public static Rescore Query(Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery rescoreQuery) => new Rescore("query", rescoreQuery); @@ -65,83 +69,76 @@ 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); + LocalJsonValue 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.TryReadProperty(ref reader, options, PropWindowSize, null)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "window_size") + if (reader.ValueTextEquals(VariantLearningToRank)) { - windowSizeValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantLearningToRank.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "learning_to_rank") + if (reader.ValueTextEquals(VariantQuery)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuery.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "query") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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) + switch (value.VariantType) { - writer.WritePropertyName("window_size"); - writer.WriteNumberValue(value.WindowSize.Value); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "learning_to_rank": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.LearningToRank)value.Variant, options); - break; - case "query": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery)value.Variant, options); - break; - } + case "": + break; + case "learning_to_rank": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LearningToRank?)value.Variant, null, null); + break; + case "query": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Rescore)}'."); } + writer.WriteProperty(options, PropWindowSize, value.WindowSize, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs index 9d3e6ebe178..83a82b1d5f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs @@ -39,12 +39,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.Core.Search.LaplaceSmoothingModel laplaceSmoothingModel) => new SmoothingModel("laplace", laplaceSmoothingModel); public static SmoothingModel LinearInterpolation(Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel linearInterpolationSmoothingModel) => new SmoothingModel("linear_interpolation", linearInterpolationSmoothingModel); @@ -63,77 +67,73 @@ 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."); + variantType = VariantLaplace.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "laplace") + if (reader.ValueTextEquals(VariantLinearInterpolation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinearInterpolation.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "linear_interpolation") + if (reader.ValueTextEquals(VariantStupidBackoff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStupidBackoff.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "stupid_backoff") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.Core.Search.LaplaceSmoothingModel)value.Variant, options); - break; - case "linear_interpolation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel)value.Variant, options); - break; - case "stupid_backoff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.StupidBackoffSmoothingModel)value.Variant, options); - break; - } + case "": + break; + case "laplace": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LaplaceSmoothingModel?)value.Variant, null, null); + break; + case "linear_interpolation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel?)value.Variant, null, null); + break; + case "stupid_backoff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.StupidBackoffSmoothingModel?)value.Variant, null, null); + 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/_Generated/Types/Core/Search/SourceFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs index ecf27ebf675..86e3350ad81 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs @@ -27,52 +27,58 @@ namespace Elastic.Clients.Elasticsearch.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) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))); + return new SourceFilter { Includes = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propExcludes = default; + LocalJsonValue propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExcludes.TryReadProperty(ref reader, options, PropExcludes, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))) || propExcludes.TryReadProperty(ref reader, options, PropExcludes1, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, 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.TryReadProperty(ref reader, options, PropIncludes, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))) || propIncludes.TryReadProperty(ref reader, options, PropIncludes1, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, 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); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropIncludes, value.Includes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs index 3cde4af0f69..988eb5c7043 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs @@ -33,9 +33,10 @@ namespace Elastic.Clients.Elasticsearch.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 +49,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) + var key = reader.ReadPropertyName(options, null); + 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, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!), + "phrase" => reader.ReadValue>(options, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!), + "term" => reader.ReadValue>(options, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!), + _ => 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Types/Core/Search/Suggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs index 4c45bb505e6..1b9c5503688 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs @@ -27,53 +27,48 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propText.TryReadProperty(ref reader, options, PropText, null)) { - 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.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, null, null); 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/_Generated/Types/Core/Search/TermSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs index c7a1b48092c..d83b58c77a9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs @@ -27,15 +27,81 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryReadProperty(ref reader, options, PropLength, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOptions.TryReadProperty(ref reader, options, PropOptions, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propText.TryReadProperty(ref reader, options, PropText, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOptions, value.Options, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropText, value.Text, null, null); + 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.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/_Generated/Types/Core/SourceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfig.g.cs index e64dca28647..dbe5d7c4319 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfig.g.cs @@ -35,13 +35,52 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; /// Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered. /// /// +[JsonConverter(typeof(SourceConfigConverter))] public sealed partial class SourceConfig : Union { - public SourceConfig(bool Fetch) : base(Fetch) + public SourceConfig(bool fetch) : base(fetch) { } - public SourceConfig(Elastic.Clients.Elasticsearch.Core.Search.SourceFilter Filter) : base(Filter) + public SourceConfig(Elastic.Clients.Elasticsearch.Core.Search.SourceFilter filter) : base(filter) { } + + public static implicit operator SourceConfig(bool fetch) => new SourceConfig(fetch); + public static implicit operator SourceConfig(Elastic.Clients.Elasticsearch.Core.Search.SourceFilter filter) => new SourceConfig(filter); +} + +internal sealed partial class SourceConfigConverter : System.Text.Json.Serialization.JsonConverter +{ + public override SourceConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.True | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.False, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new SourceConfig(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new SourceConfig(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(SourceConfig)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceConfig value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfigParam.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfigParam.g.cs index 6779a77007f..6534fd46439 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfigParam.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/SourceConfigParam.g.cs @@ -36,13 +36,52 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; /// Used as a query parameter along with the _source_includes and _source_excludes parameters. /// /// +[JsonConverter(typeof(SourceConfigParamConverter))] public sealed partial class SourceConfigParam : Union { - public SourceConfigParam(bool Fetch) : base(Fetch) + public SourceConfigParam(bool fetch) : base(fetch) { } - public SourceConfigParam(Elastic.Clients.Elasticsearch.Fields Fields) : base(Fields) + public SourceConfigParam(Elastic.Clients.Elasticsearch.Fields fields) : base(fields) { } + + public static implicit operator SourceConfigParam(bool fetch) => new SourceConfigParam(fetch); + public static implicit operator SourceConfigParam(Elastic.Clients.Elasticsearch.Fields fields) => new SourceConfigParam(fields); +} + +internal sealed partial class SourceConfigParamConverter : System.Text.Json.Serialization.JsonConverter +{ + public override SourceConfigParam Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.True | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.False, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new SourceConfigParam(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new SourceConfigParam(reader.ReadValue(options, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(SourceConfigParam)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceConfigParam value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/TrackHits.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/TrackHits.g.cs index 0d62aee06e5..018ea270ce4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/TrackHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/TrackHits.g.cs @@ -38,13 +38,52 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; /// Defaults to 10,000 hits. /// /// +[JsonConverter(typeof(TrackHitsConverter))] public sealed partial class TrackHits : Union { - public TrackHits(bool Enabled) : base(Enabled) + public TrackHits(bool enabled) : base(enabled) { } - public TrackHits(int Count) : base(Count) + public TrackHits(int count) : base(count) { } + + public static implicit operator TrackHits(bool enabled) => new TrackHits(enabled); + public static implicit operator TrackHits(int count) => new TrackHits(count); +} + +internal sealed partial class TrackHitsConverter : System.Text.Json.Serialization.JsonConverter +{ + public override TrackHits Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.True | Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.False, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new TrackHits(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new TrackHits(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(TrackHits)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TrackHits value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs index 5dc8b54516f..808f42fe819 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs @@ -27,15 +27,79 @@ namespace Elastic.Clients.Elasticsearch.DanglingIndices; +internal sealed partial class DanglingIndexConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreationDateMillis = System.Text.Json.JsonEncodedText.Encode("creation_date_millis"); + private static readonly System.Text.Json.JsonEncodedText PropIndexName = System.Text.Json.JsonEncodedText.Encode("index_name"); + private static readonly System.Text.Json.JsonEncodedText PropIndexUuid = System.Text.Json.JsonEncodedText.Encode("index_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropNodeIds = System.Text.Json.JsonEncodedText.Encode("node_ids"); + + public override DanglingIndex Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreationDateMillis = default; + LocalJsonValue propIndexName = default; + LocalJsonValue propIndexUuid = default; + LocalJsonValue> propNodeIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreationDateMillis.TryReadProperty(ref reader, options, PropCreationDateMillis, null)) + { + continue; + } + + if (propIndexName.TryReadProperty(ref reader, options, PropIndexName, null)) + { + continue; + } + + if (propIndexUuid.TryReadProperty(ref reader, options, PropIndexUuid, null)) + { + continue; + } + + if (propNodeIds.TryReadProperty(ref reader, options, PropNodeIds, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DanglingIndex + { + CreationDateMillis = propCreationDateMillis.Value +, + IndexName = propIndexName.Value +, + IndexUuid = propIndexUuid.Value +, + NodeIds = propNodeIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DanglingIndex value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreationDateMillis, value.CreationDateMillis, null, null); + writer.WriteProperty(options, PropIndexName, value.IndexName, null, null); + writer.WriteProperty(options, PropIndexUuid, value.IndexUuid, null, null); + writer.WriteProperty(options, PropNodeIds, value.NodeIds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DanglingIndexConverter))] public sealed partial class DanglingIndex { - [JsonInclude, JsonPropertyName("creation_date_millis")] public long CreationDateMillis { get; init; } - [JsonInclude, JsonPropertyName("index_name")] public string IndexName { get; init; } - [JsonInclude, JsonPropertyName("index_uuid")] public string IndexUuid { get; init; } - [JsonInclude, JsonPropertyName("node_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection NodeIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs index fc7a0cf8953..a57a485d147 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs @@ -27,20 +27,102 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propElasticsearchVersion = default; + LocalJsonValue propEnrichFields = default; + LocalJsonValue propIndices = default; + LocalJsonValue propMatchField = default; + LocalJsonValue propName = default; + LocalJsonValue propQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propElasticsearchVersion.TryReadProperty(ref reader, options, PropElasticsearchVersion, null)) + { + continue; + } + + if (propEnrichFields.TryReadProperty(ref reader, options, PropEnrichFields, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propMatchField.TryReadProperty(ref reader, options, PropMatchField, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropEnrichFields, value.EnrichFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropMatchField, value.MatchField, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + 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.Fields EnrichFields { get; set; } - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices Indices { get; set; } - [JsonInclude, JsonPropertyName("match_field")] public Elastic.Clients.Elasticsearch.Field MatchField { get; set; } - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.Name? Name { get; set; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs index bb501a37b36..fdbdabee8ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs @@ -49,74 +49,152 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, CalendarInterval value, 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYear.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberYear1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Year; + } + + if (string.Equals(value, MemberWeek.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberWeek1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Week; + } + + if (string.Equals(value, MemberSecond.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberSecond1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Second; + } + + if (string.Equals(value, MemberQuarter.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberQuarter1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Quarter; + } + + if (string.Equals(value, MemberMonth.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberMonth1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Month; + } + + if (string.Equals(value, MemberMinute.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberMinute1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Minute; + } + + if (string.Equals(value, MemberHour.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberHour1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Hour; + } + + if (string.Equals(value, MemberDay.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberDay1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CalendarInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(CalendarInterval)}'."); + } + + 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)}'."); } + } + + public override CalendarInterval ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, CalendarInterval value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -160,51 +238,102 @@ 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) + 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)) { - 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; + return CardinalityExecutionMode.Direct; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberSegmentOrdinals.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CardinalityExecutionMode.SegmentOrdinals; + } + + if (string.Equals(value, MemberSaveTimeHeuristic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CardinalityExecutionMode.SaveTimeHeuristic; + } + + if (string.Equals(value, MemberSaveMemoryHeuristic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CardinalityExecutionMode.SaveMemoryHeuristic; + } + + if (string.Equals(value, MemberGlobalOrdinals.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CardinalityExecutionMode.GlobalOrdinals; + } + + if (string.Equals(value, MemberDirect.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CardinalityExecutionMode.Direct; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override CardinalityExecutionMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, CardinalityExecutionMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -236,41 +365,74 @@ 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) + if (reader.ValueTextEquals(MemberSkip)) { - case "skip": - return GapPolicy.Skip; - case "keep_values": - return GapPolicy.KeepValues; - case "insert_zeros": - return GapPolicy.InsertZeros; + return GapPolicy.Skip; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberKeepValues)) + { + return GapPolicy.KeepValues; + } + + if (reader.ValueTextEquals(MemberInsertZeros)) + { + return GapPolicy.InsertZeros; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSkip.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GapPolicy.Skip; + } + + if (string.Equals(value, MemberKeepValues.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GapPolicy.KeepValues; + } + + if (string.Equals(value, MemberInsertZeros.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GapPolicy.InsertZeros; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override GapPolicy ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GapPolicy value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -291,56 +453,116 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYear.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MinimumInterval.Year; + } + + if (string.Equals(value, MemberSecond.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MinimumInterval.Second; + } + + if (string.Equals(value, MemberMonth.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MinimumInterval.Month; + } + + if (string.Equals(value, MemberMinute.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MinimumInterval.Minute; + } + + if (string.Equals(value, MemberHour.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return MinimumInterval.Hour; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberDay.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MinimumInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override MinimumInterval ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MinimumInterval value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -355,41 +577,74 @@ 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) + if (reader.ValueTextEquals(MemberLast)) + { + return MissingOrder.Last; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return MissingOrder.First; + } + + if (reader.ValueTextEquals(MemberDefault)) + { + return MissingOrder.Default; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberLast.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MissingOrder.Last; + } + + if (string.Equals(value, MemberFirst.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MissingOrder.First; + } + + if (string.Equals(value, MemberDefault.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "last": - return MissingOrder.Last; - case "first": - return MissingOrder.First; - case "default": - return MissingOrder.Default; + return MissingOrder.Default; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override MissingOrder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MissingOrder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -440,56 +695,116 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberZScore.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NormalizeMethod.ZScore; + } + + if (string.Equals(value, MemberSoftmax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NormalizeMethod.Softmax; + } + + if (string.Equals(value, MemberRescale0100.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NormalizeMethod.Rescale0100; + } + + if (string.Equals(value, MemberRescale01.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NormalizeMethod.Rescale01; + } + + if (string.Equals(value, MemberPercentOfSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NormalizeMethod.PercentOfSum; + } + + if (string.Equals(value, MemberMean.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return NormalizeMethod.Mean; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override NormalizeMethod ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, NormalizeMethod value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -512,36 +827,60 @@ 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) + if (reader.ValueTextEquals(MemberValueCount)) + { + return RateMode.ValueCount; + } + + if (reader.ValueTextEquals(MemberSum)) + { + return RateMode.Sum; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberValueCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RateMode.ValueCount; + } + + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "value_count": - return RateMode.ValueCount; - case "sum": - return RateMode.Sum; + return RateMode.Sum; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override RateMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RateMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -571,41 +910,74 @@ 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) + if (reader.ValueTextEquals(MemberMap)) + { + return SamplerAggregationExecutionHint.Map; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinals)) + { + return SamplerAggregationExecutionHint.GlobalOrdinals; + } + + if (reader.ValueTextEquals(MemberBytesHash)) + { + return SamplerAggregationExecutionHint.BytesHash; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberMap.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 (string.Equals(value, MemberGlobalOrdinals.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SamplerAggregationExecutionHint.GlobalOrdinals; + } + + if (string.Equals(value, MemberBytesHash.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SamplerAggregationExecutionHint.BytesHash; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SamplerAggregationExecutionHint ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SamplerAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -628,36 +1000,60 @@ 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) + if (reader.ValueTextEquals(MemberDepthFirst)) + { + return TermsAggregationCollectMode.DepthFirst; + } + + if (reader.ValueTextEquals(MemberBreadthFirst)) + { + return TermsAggregationCollectMode.BreadthFirst; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberDepthFirst.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermsAggregationCollectMode.DepthFirst; + } + + if (string.Equals(value, MemberBreadthFirst.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override TermsAggregationCollectMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TermsAggregationCollectMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -674,46 +1070,88 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberMap.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermsAggregationExecutionHint.Map; + } + + if (string.Equals(value, MemberGlobalOrdinalsLowCardinality.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality; + } + + if (string.Equals(value, MemberGlobalOrdinalsHash.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsHash; + } + + if (string.Equals(value, MemberGlobalOrdinals.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermsAggregationExecutionHint.GlobalOrdinals; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TermsAggregationExecutionHint ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TermsAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -743,41 +1181,74 @@ 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) + if (reader.ValueTextEquals(MemberPaired)) + { + return TTestType.Paired; + } + + if (reader.ValueTextEquals(MemberHomoscedastic)) + { + return TTestType.Homoscedastic; + } + + if (reader.ValueTextEquals(MemberHeteroscedastic)) + { + return TTestType.Heteroscedastic; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPaired.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TTestType.Paired; + } + + if (string.Equals(value, MemberHomoscedastic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TTestType.Homoscedastic; + } + + if (string.Equals(value, MemberHeteroscedastic.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "paired": - return TTestType.Paired; - case "homoscedastic": - return TTestType.Homoscedastic; - case "heteroscedastic": - return TTestType.Heteroscedastic; + return TTestType.Heteroscedastic; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TTestType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TTestType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -806,75 +1277,171 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, ValueType value, 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberString.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.String; + } + + if (string.Equals(value, MemberNumeric.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Numeric; + } + + if (string.Equals(value, MemberNumber.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Number; + } + + if (string.Equals(value, MemberLong.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Long; + } + + if (string.Equals(value, MemberIp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Ip; + } + + if (string.Equals(value, MemberGeoPoint.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.GeoPoint; + } + + if (string.Equals(value, MemberDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Double; + } + + if (string.Equals(value, MemberDateNanos.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.DateNanos; + } + + if (string.Equals(value, MemberDate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Date; + } + + if (string.Equals(value, MemberBoolean.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ValueType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(ValueType)}'."); + } + + 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(); + public override ValueType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ValueType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs index dae02bf828f..e2e406e846f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs @@ -39,41 +39,74 @@ 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) + if (reader.ValueTextEquals(MemberInteger)) + { + return DelimitedPayloadEncoding.Integer; + } + + if (reader.ValueTextEquals(MemberIdentity)) + { + return DelimitedPayloadEncoding.Identity; + } + + if (reader.ValueTextEquals(MemberFloat)) + { + return DelimitedPayloadEncoding.Float; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberInteger.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DelimitedPayloadEncoding.Integer; + } + + if (string.Equals(value, MemberIdentity.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DelimitedPayloadEncoding.Identity; + } + + if (string.Equals(value, MemberFloat.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override DelimitedPayloadEncoding ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DelimitedPayloadEncoding value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -86,36 +119,60 @@ 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) + if (reader.ValueTextEquals(MemberFront)) + { + return EdgeNGramSide.Front; + } + + if (reader.ValueTextEquals(MemberBack)) + { + return EdgeNGramSide.Back; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberFront.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "front": - return EdgeNGramSide.Front; - case "back": - return EdgeNGramSide.Back; + return EdgeNGramSide.Front; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberBack.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EdgeNGramSide.Back; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override EdgeNGramSide ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, EdgeNGramSide value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -128,36 +185,60 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberShifted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationAlternate.Shifted; + } + + if (string.Equals(value, MemberNonIgnorable.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationAlternate.NonIgnorable; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuCollationAlternate ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuCollationAlternate value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -170,36 +251,60 @@ 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) + if (reader.ValueTextEquals(MemberUpper)) + { + return IcuCollationCaseFirst.Upper; + } + + if (reader.ValueTextEquals(MemberLower)) + { + return IcuCollationCaseFirst.Lower; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUpper.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationCaseFirst.Upper; + } + + if (string.Equals(value, MemberLower.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "upper": - return IcuCollationCaseFirst.Upper; - case "lower": - return IcuCollationCaseFirst.Lower; + return IcuCollationCaseFirst.Lower; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuCollationCaseFirst ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuCollationCaseFirst value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -212,36 +317,60 @@ 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) + if (reader.ValueTextEquals(MemberNo)) + { + return IcuCollationDecomposition.No; + } + + if (reader.ValueTextEquals(MemberIdentical)) + { + return IcuCollationDecomposition.Identical; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationDecomposition.No; + } + + if (string.Equals(value, MemberIdentical.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "no": - return IcuCollationDecomposition.No; - case "identical": - return IcuCollationDecomposition.Identical; + return IcuCollationDecomposition.Identical; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuCollationDecomposition ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuCollationDecomposition value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -260,51 +389,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTertiary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationStrength.Tertiary; + } + + if (string.Equals(value, MemberSecondary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationStrength.Secondary; + } + + if (string.Equals(value, MemberQuaternary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationStrength.Quaternary; + } + + if (string.Equals(value, MemberPrimary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuCollationStrength.Primary; + } + + if (string.Equals(value, MemberIdentical.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return IcuCollationStrength.Identical; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuCollationStrength ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuCollationStrength value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -317,36 +497,60 @@ 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) + if (reader.ValueTextEquals(MemberDecompose)) + { + return IcuNormalizationMode.Decompose; + } + + if (reader.ValueTextEquals(MemberCompose)) + { + return IcuNormalizationMode.Compose; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberDecompose.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuNormalizationMode.Decompose; + } + + if (string.Equals(value, MemberCompose.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "decompose": - return IcuNormalizationMode.Decompose; - case "compose": - return IcuNormalizationMode.Compose; + return IcuNormalizationMode.Compose; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuNormalizationMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -361,41 +565,74 @@ 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) + if (reader.ValueTextEquals(MemberNfkcCf)) + { + return IcuNormalizationType.NfkcCf; + } + + if (reader.ValueTextEquals(MemberNfkc)) + { + return IcuNormalizationType.Nfkc; + } + + if (reader.ValueTextEquals(MemberNfc)) + { + return IcuNormalizationType.Nfc; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNfkcCf.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuNormalizationType.NfkcCf; + } + + if (string.Equals(value, MemberNfkc.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuNormalizationType.Nfkc; + } + + if (string.Equals(value, MemberNfc.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override IcuNormalizationType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -408,36 +645,60 @@ 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) + if (reader.ValueTextEquals(MemberReverse)) + { + return IcuTransformDirection.Reverse; + } + + if (reader.ValueTextEquals(MemberForward)) + { + return IcuTransformDirection.Forward; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberReverse.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IcuTransformDirection.Reverse; + } + + if (string.Equals(value, MemberForward.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "reverse": - return IcuTransformDirection.Reverse; - case "forward": - return IcuTransformDirection.Forward; + return IcuTransformDirection.Forward; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IcuTransformDirection ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IcuTransformDirection value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -450,36 +711,60 @@ 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) + if (reader.ValueTextEquals(MemberInclude)) + { + return KeepTypesMode.Include; + } + + if (reader.ValueTextEquals(MemberExclude)) + { + return KeepTypesMode.Exclude; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberInclude.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "include": - return KeepTypesMode.Include; - case "exclude": - return KeepTypesMode.Exclude; + return KeepTypesMode.Include; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberExclude.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return KeepTypesMode.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override KeepTypesMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, KeepTypesMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -494,41 +779,74 @@ 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) + if (reader.ValueTextEquals(MemberSearch)) + { + return KuromojiTokenizationMode.Search; + } + + if (reader.ValueTextEquals(MemberNormal)) + { + return KuromojiTokenizationMode.Normal; + } + + if (reader.ValueTextEquals(MemberExtended)) + { + return KuromojiTokenizationMode.Extended; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSearch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return KuromojiTokenizationMode.Search; + } + + if (string.Equals(value, MemberNormal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return KuromojiTokenizationMode.Normal; + } + + if (string.Equals(value, MemberExtended.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "search": - return KuromojiTokenizationMode.Search; - case "normal": - return KuromojiTokenizationMode.Normal; - case "extended": - return KuromojiTokenizationMode.Extended; + return KuromojiTokenizationMode.Extended; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override KuromojiTokenizationMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, KuromojiTokenizationMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -605,245 +923,590 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, Language value, 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) { - switch (value) + if (reader.ValueTextEquals(MemberTurkish)) { - case Language.Turkish: - writer.WriteStringValue("Turkish"); - return; - case Language.Thai: - writer.WriteStringValue("Thai"); - return; - case Language.Swedish: - writer.WriteStringValue("Swedish"); - return; - case Language.Spanish: - writer.WriteStringValue("Spanish"); - return; - case Language.Sorani: - writer.WriteStringValue("Sorani"); - return; - case Language.Russian: - writer.WriteStringValue("Russian"); - return; - case Language.Romanian: - writer.WriteStringValue("Romanian"); - return; - case Language.Portuguese: - writer.WriteStringValue("Portuguese"); - return; - case Language.Persian: - writer.WriteStringValue("Persian"); - return; - case Language.Norwegian: - writer.WriteStringValue("Norwegian"); - return; - case Language.Latvian: - writer.WriteStringValue("Latvian"); - return; - case Language.Italian: - writer.WriteStringValue("Italian"); - return; - case Language.Irish: - writer.WriteStringValue("Irish"); - return; - case Language.Indonesian: - writer.WriteStringValue("Indonesian"); - return; - case Language.Hungarian: - writer.WriteStringValue("Hungarian"); - return; - case Language.Hindi: - writer.WriteStringValue("Hindi"); - return; - case Language.Greek: - writer.WriteStringValue("Greek"); - return; - case Language.German: - writer.WriteStringValue("German"); - return; - case Language.Galician: - writer.WriteStringValue("Galician"); - return; - case Language.French: - writer.WriteStringValue("French"); - return; - case Language.Finnish: - writer.WriteStringValue("Finnish"); - return; - case Language.Estonian: - writer.WriteStringValue("Estonian"); - return; - case Language.English: - writer.WriteStringValue("English"); - return; - case Language.Dutch: - writer.WriteStringValue("Dutch"); - return; - case Language.Danish: - writer.WriteStringValue("Danish"); - return; - case Language.Czech: - writer.WriteStringValue("Czech"); - return; - case Language.Cjk: - writer.WriteStringValue("Cjk"); - return; - case Language.Chinese: - writer.WriteStringValue("Chinese"); - return; - case Language.Catalan: - writer.WriteStringValue("Catalan"); - return; - case Language.Bulgarian: - writer.WriteStringValue("Bulgarian"); - return; - case Language.Brazilian: - writer.WriteStringValue("Brazilian"); - return; - case Language.Basque: - writer.WriteStringValue("Basque"); - return; - case Language.Armenian: - writer.WriteStringValue("Armenian"); - return; - case Language.Arabic: - writer.WriteStringValue("Arabic"); - return; + return Language.Turkish; } - writer.WriteNullValue(); - } -} - -[JsonConverter(typeof(NoriDecompoundModeConverter))] -public enum NoriDecompoundMode -{ - [EnumMember(Value = "none")] - None, - [EnumMember(Value = "mixed")] - Mixed, - [EnumMember(Value = "discard")] - Discard -} + if (reader.ValueTextEquals(MemberThai)) + { + return Language.Thai; + } -internal sealed class NoriDecompoundModeConverter : JsonConverter -{ - public override NoriDecompoundMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberSwedish)) { - case "none": - return NoriDecompoundMode.None; - case "mixed": - return NoriDecompoundMode.Mixed; - case "discard": - return NoriDecompoundMode.Discard; + return Language.Swedish; } - ThrowHelper.ThrowJsonException(); - return default; - } + if (reader.ValueTextEquals(MemberSpanish)) + { + return Language.Spanish; + } - public override void Write(Utf8JsonWriter writer, NoriDecompoundMode value, JsonSerializerOptions options) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTurkish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Turkish; + } + + if (string.Equals(value, MemberThai.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Thai; + } + + if (string.Equals(value, MemberSwedish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Swedish; + } + + if (string.Equals(value, MemberSpanish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Spanish; + } + + if (string.Equals(value, MemberSorani.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Sorani; + } + + if (string.Equals(value, MemberRussian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Russian; + } + + if (string.Equals(value, MemberRomanian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Romanian; + } + + if (string.Equals(value, MemberPortuguese.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Portuguese; + } + + if (string.Equals(value, MemberPersian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Persian; + } + + if (string.Equals(value, MemberNorwegian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Norwegian; + } + + if (string.Equals(value, MemberLatvian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Latvian; + } + + if (string.Equals(value, MemberItalian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Italian; + } + + if (string.Equals(value, MemberIrish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Irish; + } + + if (string.Equals(value, MemberIndonesian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Indonesian; + } + + if (string.Equals(value, MemberHungarian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Hungarian; + } + + if (string.Equals(value, MemberHindi.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Hindi; + } + + if (string.Equals(value, MemberGreek.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Greek; + } + + if (string.Equals(value, MemberGerman.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.German; + } + + if (string.Equals(value, MemberGalician.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Galician; + } + + if (string.Equals(value, MemberFrench.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.French; + } + + if (string.Equals(value, MemberFinnish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Finnish; + } + + if (string.Equals(value, MemberEstonian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Estonian; + } + + if (string.Equals(value, MemberEnglish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.English; + } + + if (string.Equals(value, MemberDutch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Dutch; + } + + if (string.Equals(value, MemberDanish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Danish; + } + + if (string.Equals(value, MemberCzech.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Czech; + } + + if (string.Equals(value, MemberCjk.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Cjk; + } + + if (string.Equals(value, MemberChinese.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Chinese; + } + + if (string.Equals(value, MemberCatalan.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Catalan; + } + + if (string.Equals(value, MemberBulgarian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Bulgarian; + } + + if (string.Equals(value, MemberBrazilian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Brazilian; + } + + if (string.Equals(value, MemberBasque.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Basque; + } + + if (string.Equals(value, MemberArmenian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Armenian; + } + + if (string.Equals(value, MemberArabic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Language.Arabic; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(Language)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Language value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Language.Turkish: + writer.WriteStringValue(MemberTurkish); + break; + case Language.Thai: + writer.WriteStringValue(MemberThai); + break; + case Language.Swedish: + writer.WriteStringValue(MemberSwedish); + break; + case Language.Spanish: + writer.WriteStringValue(MemberSpanish); + break; + case Language.Sorani: + writer.WriteStringValue(MemberSorani); + break; + case Language.Russian: + writer.WriteStringValue(MemberRussian); + break; + case Language.Romanian: + writer.WriteStringValue(MemberRomanian); + break; + case Language.Portuguese: + writer.WriteStringValue(MemberPortuguese); + break; + case Language.Persian: + writer.WriteStringValue(MemberPersian); + break; + case Language.Norwegian: + writer.WriteStringValue(MemberNorwegian); + break; + case Language.Latvian: + writer.WriteStringValue(MemberLatvian); + break; + case Language.Italian: + writer.WriteStringValue(MemberItalian); + break; + case Language.Irish: + writer.WriteStringValue(MemberIrish); + break; + case Language.Indonesian: + writer.WriteStringValue(MemberIndonesian); + break; + case Language.Hungarian: + writer.WriteStringValue(MemberHungarian); + break; + case Language.Hindi: + writer.WriteStringValue(MemberHindi); + break; + case Language.Greek: + writer.WriteStringValue(MemberGreek); + break; + case Language.German: + writer.WriteStringValue(MemberGerman); + break; + case Language.Galician: + writer.WriteStringValue(MemberGalician); + break; + case Language.French: + writer.WriteStringValue(MemberFrench); + break; + case Language.Finnish: + writer.WriteStringValue(MemberFinnish); + break; + case Language.Estonian: + writer.WriteStringValue(MemberEstonian); + break; + case Language.English: + writer.WriteStringValue(MemberEnglish); + break; + case Language.Dutch: + writer.WriteStringValue(MemberDutch); + break; + case Language.Danish: + writer.WriteStringValue(MemberDanish); + break; + case Language.Czech: + writer.WriteStringValue(MemberCzech); + break; + case Language.Cjk: + writer.WriteStringValue(MemberCjk); + break; + case Language.Chinese: + writer.WriteStringValue(MemberChinese); + break; + case Language.Catalan: + writer.WriteStringValue(MemberCatalan); + break; + case Language.Bulgarian: + writer.WriteStringValue(MemberBulgarian); + break; + case Language.Brazilian: + writer.WriteStringValue(MemberBrazilian); + break; + case Language.Basque: + writer.WriteStringValue(MemberBasque); + break; + case Language.Armenian: + writer.WriteStringValue(MemberArmenian); + break; + case Language.Arabic: + writer.WriteStringValue(MemberArabic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Language)}'."); + } + } + + public override Language ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Language value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} + +[JsonConverter(typeof(NoriDecompoundModeConverter))] +public enum NoriDecompoundMode +{ + [EnumMember(Value = "none")] + None, + [EnumMember(Value = "mixed")] + Mixed, + [EnumMember(Value = "discard")] + Discard +} + +internal sealed partial class NoriDecompoundModeConverter : System.Text.Json.Serialization.JsonConverter +{ + 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) + { + if (reader.ValueTextEquals(MemberNone)) + { + return NoriDecompoundMode.None; + } + + if (reader.ValueTextEquals(MemberMixed)) + { + return NoriDecompoundMode.Mixed; + } + + if (reader.ValueTextEquals(MemberDiscard)) + { + return NoriDecompoundMode.Discard; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NoriDecompoundMode.None; + } + + if (string.Equals(value, MemberMixed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NoriDecompoundMode.Mixed; + } + + if (string.Equals(value, MemberDiscard.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NoriDecompoundMode.Discard; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(NoriDecompoundMode)}'."); + } + + 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(); + public override NoriDecompoundMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, NoriDecompoundMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -876,86 +1539,200 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, PhoneticEncoder value, 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSoundex.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Soundex; + } + + if (string.Equals(value, MemberRefinedSoundex.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.RefinedSoundex; + } + + if (string.Equals(value, MemberNysiis.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Nysiis; + } + + if (string.Equals(value, MemberMetaphone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Metaphone; + } + + if (string.Equals(value, MemberKoelnerphonetik.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Koelnerphonetik; + } + + if (string.Equals(value, MemberHaasephonetik.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Haasephonetik; + } + + if (string.Equals(value, MemberDoubleMetaphone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.DoubleMetaphone; + } + + if (string.Equals(value, MemberDaitchMokotoff.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.DaitchMokotoff; + } + + if (string.Equals(value, MemberCologne.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Cologne; + } + + if (string.Equals(value, MemberCaverphone2.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Caverphone2; + } + + if (string.Equals(value, MemberCaverphone1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.Caverphone1; + } + + if (string.Equals(value, MemberBeiderMorse.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticEncoder.BeiderMorse; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(PhoneticEncoder)}'."); + } + + 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(); + public override PhoneticEncoder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, PhoneticEncoder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -988,86 +1765,200 @@ public enum PhoneticLanguage Any } -internal sealed class PhoneticLanguageConverter : JsonConverter -{ - public override PhoneticLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, 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; - } - - public override void Write(Utf8JsonWriter writer, PhoneticLanguage value, JsonSerializerOptions options) +internal sealed partial class PhoneticLanguageConverter : System.Text.Json.Serialization.JsonConverter +{ + 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSpanish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Spanish; + } + + if (string.Equals(value, MemberRussian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Russian; + } + + if (string.Equals(value, MemberRomanian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Romanian; + } + + if (string.Equals(value, MemberPolish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Polish; + } + + if (string.Equals(value, MemberHungarian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Hungarian; + } + + if (string.Equals(value, MemberHebrew.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Hebrew; + } + + if (string.Equals(value, MemberGerman.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.German; + } + + if (string.Equals(value, MemberFrench.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.French; + } + + if (string.Equals(value, MemberEnglish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.English; + } + + if (string.Equals(value, MemberCyrillic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Cyrillic; + } + + if (string.Equals(value, MemberCommon.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Common; + } + + if (string.Equals(value, MemberAny.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticLanguage.Any; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(PhoneticLanguage)}'."); + } + + 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)}'."); } + } + + public override PhoneticLanguage ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, PhoneticLanguage value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1082,41 +1973,74 @@ 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) + if (reader.ValueTextEquals(MemberSephardic)) + { + return PhoneticNameType.Sephardic; + } + + if (reader.ValueTextEquals(MemberGeneric)) + { + return PhoneticNameType.Generic; + } + + if (reader.ValueTextEquals(MemberAshkenazi)) + { + return PhoneticNameType.Ashkenazi; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSephardic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticNameType.Sephardic; + } + + if (string.Equals(value, MemberGeneric.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "sephardic": - return PhoneticNameType.Sephardic; - case "generic": - return PhoneticNameType.Generic; - case "ashkenazi": - return PhoneticNameType.Ashkenazi; + return PhoneticNameType.Generic; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberAshkenazi.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticNameType.Ashkenazi; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override PhoneticNameType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, PhoneticNameType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1129,36 +2053,60 @@ 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) + if (reader.ValueTextEquals(MemberExact)) + { + return PhoneticRuleType.Exact; + } + + if (reader.ValueTextEquals(MemberApprox)) + { + return PhoneticRuleType.Approx; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberExact.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PhoneticRuleType.Exact; + } + + if (string.Equals(value, MemberApprox.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "exact": - return PhoneticRuleType.Exact; - case "approx": - return PhoneticRuleType.Approx; + return PhoneticRuleType.Approx; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override PhoneticRuleType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, PhoneticRuleType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1211,136 +2159,340 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, SnowballLanguage value, 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTurkish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Turkish; + } + + if (string.Equals(value, MemberSwedish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Swedish; + } + + if (string.Equals(value, MemberSpanish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Spanish; + } + + if (string.Equals(value, MemberRussian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Russian; + } + + if (string.Equals(value, MemberRomanian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Romanian; + } + + if (string.Equals(value, MemberPortuguese.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Portuguese; + } + + if (string.Equals(value, MemberPorter.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Porter; + } + + if (string.Equals(value, MemberNorwegian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Norwegian; + } + + if (string.Equals(value, MemberLovins.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Lovins; + } + + if (string.Equals(value, MemberKp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Kp; + } + + if (string.Equals(value, MemberItalian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Italian; + } + + if (string.Equals(value, MemberHungarian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Hungarian; + } + + if (string.Equals(value, MemberGerman2.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.German2; + } + + if (string.Equals(value, MemberGerman.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.German; + } + + if (string.Equals(value, MemberFrench.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.French; + } + + if (string.Equals(value, MemberFinnish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Finnish; + } + + if (string.Equals(value, MemberEnglish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.English; + } + + if (string.Equals(value, MemberDutch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Dutch; + } + + if (string.Equals(value, MemberDanish.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Danish; + } + + if (string.Equals(value, MemberCatalan.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Catalan; + } + + if (string.Equals(value, MemberBasque.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Basque; + } + + if (string.Equals(value, MemberArmenian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnowballLanguage.Armenian; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(SnowballLanguage)}'."); + } + + 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)}'."); } + } + + public override SnowballLanguage ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SnowballLanguage value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1353,36 +2505,60 @@ 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) + if (reader.ValueTextEquals(MemberWordnet)) + { + return SynonymFormat.Wordnet; + } + + if (reader.ValueTextEquals(MemberSolr)) + { + return SynonymFormat.Solr; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWordnet.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SynonymFormat.Wordnet; + } + + if (string.Equals(value, MemberSolr.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "wordnet": - return SynonymFormat.Wordnet; - case "solr": - return SynonymFormat.Solr; + return SynonymFormat.Solr; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SynonymFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SynonymFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1403,55 +2579,115 @@ 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) + if (reader.ValueTextEquals(MemberWhitespace)) + { + return TokenChar.Whitespace; + } + + if (reader.ValueTextEquals(MemberSymbol)) + { + return TokenChar.Symbol; + } + + if (reader.ValueTextEquals(MemberPunctuation)) { - 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; + return TokenChar.Punctuation; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLetter)) + { + return TokenChar.Letter; + } + + if (reader.ValueTextEquals(MemberDigit)) + { + return TokenChar.Digit; + } + + if (reader.ValueTextEquals(MemberCustom)) + { + return TokenChar.Custom; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWhitespace.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Whitespace; + } + + if (string.Equals(value, MemberSymbol.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Symbol; + } + + if (string.Equals(value, MemberPunctuation.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Punctuation; + } + + if (string.Equals(value, MemberLetter.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Letter; + } + + if (string.Equals(value, MemberDigit.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Digit; + } + + if (string.Equals(value, MemberCustom.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenChar.Custom; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TokenChar ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TokenChar value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs index f8a92c8f479..1f05dffcff1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs @@ -41,46 +41,88 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberYes.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AllocationExplainDecision.Yes; + } + + if (string.Equals(value, MemberThrottle.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AllocationExplainDecision.Throttle; + } + + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AllocationExplainDecision.No; + } + + if (string.Equals(value, MemberAlways.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AllocationExplainDecision.Always; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override AllocationExplainDecision ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, AllocationExplainDecision value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -105,66 +147,144 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberYes)) + { + return Decision.Yes; + } + + if (reader.ValueTextEquals(MemberWorseBalance)) + { + return Decision.WorseBalance; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYes.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.Yes; + } + + if (string.Equals(value, MemberWorseBalance.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.WorseBalance; + } + + if (string.Equals(value, MemberThrottled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.Throttled; + } + + if (string.Equals(value, MemberNoValidShardCopy.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.NoValidShardCopy; + } + + if (string.Equals(value, MemberNoAttempt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.NoAttempt; + } + + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.No; + } + + if (string.Equals(value, MemberAwaitingInfo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.AwaitingInfo; + } + + if (string.Equals(value, MemberAllocationDelayed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Decision.AllocationDelayed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override Decision ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Decision value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -203,100 +323,241 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + 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)) + { + return UnassignedInformationReason.IndexReopened; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRerouteCancelled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.RerouteCancelled; + } + + if (string.Equals(value, MemberReplicaAdded.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ReplicaAdded; + } + + if (string.Equals(value, MemberReinitialized.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.Reinitialized; + } + + if (string.Equals(value, MemberReallocatedReplica.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ReallocatedReplica; + } + + if (string.Equals(value, MemberPrimaryFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.PrimaryFailed; + } + + if (string.Equals(value, MemberNodeLeft.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.NodeLeft; + } + + if (string.Equals(value, MemberNewIndexRestored.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.NewIndexRestored; + } + + if (string.Equals(value, MemberManualAllocation.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ManualAllocation; + } + + if (string.Equals(value, MemberIndexReopened.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.IndexReopened; + } + + if (string.Equals(value, MemberIndexCreated.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.IndexCreated; + } + + if (string.Equals(value, MemberForcedEmptyPrimary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ForcedEmptyPrimary; + } + + if (string.Equals(value, MemberExistingIndexRestored.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ExistingIndexRestored; + } + + if (string.Equals(value, MemberDanglingIndexImported.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.DanglingIndexImported; + } + + if (string.Equals(value, MemberClusterRecovered.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.ClusterRecovered; + } + + if (string.Equals(value, MemberAllocationFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UnassignedInformationReason.AllocationFailed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override UnassignedInformationReason ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, UnassignedInformationReason value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Bulk.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Bulk.g.cs new file mode 100644 index 00000000000..3078aecafea --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Bulk.g.cs @@ -0,0 +1,127 @@ +// 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.Core; +using Elastic.Clients.Elasticsearch.Serialization; +using Elastic.Transport; +using System; +using System.Runtime.Serialization; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Core.Bulk; + +[JsonConverter(typeof(OperationTypeConverter))] +public enum OperationType +{ + [EnumMember(Value = "update")] + Update, + [EnumMember(Value = "index")] + Index, + [EnumMember(Value = "delete")] + Delete, + [EnumMember(Value = "create")] + Create +} + +internal sealed partial class OperationTypeConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText MemberUpdate = System.Text.Json.JsonEncodedText.Encode("update"); + private static readonly System.Text.Json.JsonEncodedText MemberIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText MemberDelete = System.Text.Json.JsonEncodedText.Encode("delete"); + private static readonly System.Text.Json.JsonEncodedText MemberCreate = System.Text.Json.JsonEncodedText.Encode("create"); + + public override OperationType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.ValueTextEquals(MemberUpdate)) + { + return OperationType.Update; + } + + if (reader.ValueTextEquals(MemberIndex)) + { + return OperationType.Index; + } + + if (reader.ValueTextEquals(MemberDelete)) + { + return OperationType.Delete; + } + + if (reader.ValueTextEquals(MemberCreate)) + { + return OperationType.Create; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUpdate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return OperationType.Update; + } + + if (string.Equals(value, MemberIndex.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return OperationType.Index; + } + + if (string.Equals(value, MemberDelete.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return OperationType.Delete; + } + + if (string.Equals(value, MemberCreate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return OperationType.Create; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(OperationType)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OperationType value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case OperationType.Update: + writer.WriteStringValue(MemberUpdate); + break; + case OperationType.Index: + writer.WriteStringValue(MemberIndex); + break; + case OperationType.Delete: + writer.WriteStringValue(MemberDelete); + break; + case OperationType.Create: + writer.WriteStringValue(MemberCreate); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(OperationType)}'."); + } + } + + public override OperationType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, OperationType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs index c3bc56ecfd4..c4309abe964 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs @@ -41,46 +41,88 @@ 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) + if (reader.ValueTextEquals(MemberSearch)) + { + return ImpactArea.Search; + } + + if (reader.ValueTextEquals(MemberIngest)) + { + return ImpactArea.Ingest; + } + + if (reader.ValueTextEquals(MemberDeploymentManagement)) { - case "search": - return ImpactArea.Search; - case "ingest": - return ImpactArea.Ingest; - case "deployment_management": - return ImpactArea.DeploymentManagement; - case "backup": - return ImpactArea.Backup; + return ImpactArea.DeploymentManagement; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberBackup)) + { + return ImpactArea.Backup; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSearch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ImpactArea.Search; + } + + if (string.Equals(value, MemberIngest.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ImpactArea.Ingest; + } + + if (string.Equals(value, MemberDeploymentManagement.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ImpactArea.DeploymentManagement; + } + + if (string.Equals(value, MemberBackup.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ImpactArea.Backup; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ImpactArea ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ImpactArea value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -97,45 +139,87 @@ 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) + if (reader.ValueTextEquals(MemberYellow)) + { + return IndicatorHealthStatus.Yellow; + } + + if (reader.ValueTextEquals(MemberUnknown)) + { + return IndicatorHealthStatus.Unknown; + } + + if (reader.ValueTextEquals(MemberRed)) { - case "yellow": - return IndicatorHealthStatus.Yellow; - case "unknown": - return IndicatorHealthStatus.Unknown; - case "red": - return IndicatorHealthStatus.Red; - case "green": - return IndicatorHealthStatus.Green; + return IndicatorHealthStatus.Red; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGreen)) + { + return IndicatorHealthStatus.Green; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYellow.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndicatorHealthStatus.Yellow; + } + + if (string.Equals(value, MemberUnknown.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndicatorHealthStatus.Unknown; + } + + if (string.Equals(value, MemberRed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndicatorHealthStatus.Red; + } + + if (string.Equals(value, MemberGreen.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndicatorHealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IndicatorHealthStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndicatorHealthStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs index d585ddc3ee1..a6e01bf01e7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs @@ -60,41 +60,74 @@ 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) + if (reader.ValueTextEquals(MemberWord)) + { + return BoundaryScanner.Word; + } + + if (reader.ValueTextEquals(MemberSentence)) { - case "word": - return BoundaryScanner.Word; - case "sentence": - return BoundaryScanner.Sentence; - case "chars": - return BoundaryScanner.Chars; + return BoundaryScanner.Sentence; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberChars)) + { + return BoundaryScanner.Chars; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWord.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return BoundaryScanner.Word; + } + + if (string.Equals(value, MemberSentence.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return BoundaryScanner.Sentence; + } + + if (string.Equals(value, MemberChars.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return BoundaryScanner.Chars; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override BoundaryScanner ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, BoundaryScanner value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -107,36 +140,60 @@ 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) + if (reader.ValueTextEquals(MemberHtml)) + { + return HighlighterEncoder.Html; + } + + if (reader.ValueTextEquals(MemberDefault)) { - case "html": - return HighlighterEncoder.Html; - case "default": - return HighlighterEncoder.Default; + return HighlighterEncoder.Default; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberHtml.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HighlighterEncoder.Html; + } + + if (string.Equals(value, MemberDefault.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HighlighterEncoder.Default; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override HighlighterEncoder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HighlighterEncoder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -149,36 +206,60 @@ 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) + if (reader.ValueTextEquals(MemberSpan)) + { + return HighlighterFragmenter.Span; + } + + if (reader.ValueTextEquals(MemberSimple)) + { + return HighlighterFragmenter.Simple; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSpan.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HighlighterFragmenter.Span; + } + + if (string.Equals(value, MemberSimple.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "span": - return HighlighterFragmenter.Span; - case "simple": - return HighlighterFragmenter.Simple; + return HighlighterFragmenter.Simple; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override HighlighterFragmenter ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HighlighterFragmenter value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -189,31 +270,46 @@ 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) + if (reader.ValueTextEquals(MemberScore)) { - case "score": - return HighlighterOrder.Score; + return HighlighterOrder.Score; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberScore.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HighlighterOrder.Score; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override HighlighterOrder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HighlighterOrder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -224,31 +320,46 @@ 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) + if (reader.ValueTextEquals(MemberStyled)) + { + return HighlighterTagsSchema.Styled; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStyled.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "styled": - return HighlighterTagsSchema.Styled; + return HighlighterTagsSchema.Styled; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override HighlighterTagsSchema ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HighlighterTagsSchema value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -256,9 +367,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 +449,102 @@ 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) + 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)) { - 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; + return ScoreMode.Avg; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberTotal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScoreMode.Total; + } + + if (string.Equals(value, MemberMultiply.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScoreMode.Multiply; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScoreMode.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScoreMode.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ScoreMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ScoreMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -424,51 +588,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNgram.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StringDistance.Ngram; + } + + if (string.Equals(value, MemberLevenshtein.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StringDistance.Levenshtein; + } + + if (string.Equals(value, MemberJaroWinkler.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return StringDistance.JaroWinkler; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberInternal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StringDistance.Internal; + } + + if (string.Equals(value, MemberDamerauLevenshtein.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StringDistance.DamerauLevenshtein; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override StringDistance ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, StringDistance value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -491,36 +706,60 @@ 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) + if (reader.ValueTextEquals(MemberScore)) + { + return SuggestSort.Score; + } + + if (reader.ValueTextEquals(MemberFrequency)) + { + return SuggestSort.Frequency; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberScore.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SuggestSort.Score; + } + + if (string.Equals(value, MemberFrequency.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "score": - return SuggestSort.Score; - case "frequency": - return SuggestSort.Frequency; + return SuggestSort.Frequency; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SuggestSort ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SuggestSort value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -543,35 +782,59 @@ 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) + if (reader.ValueTextEquals(MemberGte)) + { + return TotalHitsRelation.Gte; + } + + if (reader.ValueTextEquals(MemberEq)) + { + return TotalHitsRelation.Eq; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberGte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TotalHitsRelation.Gte; + } + + if (string.Equals(value, MemberEq.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "gte": - return TotalHitsRelation.Gte; - case "eq": - return TotalHitsRelation.Eq; + return TotalHitsRelation.Eq; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TotalHitsRelation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TotalHitsRelation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs index ba5a373ae24..c76f1335c77 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs @@ -37,36 +37,60 @@ 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) + if (reader.ValueTextEquals(MemberGeotile)) + { + return GridAggregationType.Geotile; + } + + if (reader.ValueTextEquals(MemberGeohex)) + { + return GridAggregationType.Geohex; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberGeotile.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GridAggregationType.Geotile; + } + + if (string.Equals(value, MemberGeohex.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "geotile": - return GridAggregationType.Geotile; - case "geohex": - return GridAggregationType.Geohex; + return GridAggregationType.Geohex; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override GridAggregationType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GridAggregationType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -81,40 +105,73 @@ 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) + if (reader.ValueTextEquals(MemberPoint)) + { + return GridType.Point; + } + + if (reader.ValueTextEquals(MemberGrid)) + { + return GridType.Grid; + } + + if (reader.ValueTextEquals(MemberCentroid)) + { + return GridType.Centroid; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPoint.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GridType.Point; + } + + if (string.Equals(value, MemberGrid.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "point": - return GridType.Point; - case "grid": - return GridType.Grid; - case "centroid": - return GridType.Centroid; + return GridType.Grid; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberCentroid.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GridType.Centroid; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override GridType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GridType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs index b7c7782a161..1eabf583a6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs @@ -37,35 +37,59 @@ public enum FollowerIndexStatus Active } -internal sealed class FollowerIndexStatusConverter : JsonConverter +internal sealed partial class FollowerIndexStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override FollowerIndexStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPaused = System.Text.Json.JsonEncodedText.Encode("paused"); + private static readonly System.Text.Json.JsonEncodedText MemberActive = System.Text.Json.JsonEncodedText.Encode("active"); + + public override FollowerIndexStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberPaused)) + { + return FollowerIndexStatus.Paused; + } + + if (reader.ValueTextEquals(MemberActive)) { - case "paused": - return FollowerIndexStatus.Paused; - case "active": - return FollowerIndexStatus.Active; + return FollowerIndexStatus.Active; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberPaused.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FollowerIndexStatus.Paused; + } + + if (string.Equals(value, MemberActive.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FollowerIndexStatus.Active; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(FollowerIndexStatus)}'."); } - public override void Write(Utf8JsonWriter writer, FollowerIndexStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowerIndexStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FollowerIndexStatus.Paused: - writer.WriteStringValue("paused"); - return; + writer.WriteStringValue(MemberPaused); + break; case FollowerIndexStatus.Active: - writer.WriteStringValue("active"); - return; + writer.WriteStringValue(MemberActive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FollowerIndexStatus)}'."); } + } - writer.WriteNullValue(); + public override FollowerIndexStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FollowerIndexStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs index e515e745ac1..0d46d924f67 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs @@ -41,46 +41,88 @@ 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) + 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)) + { + return EnrichPolicyPhase.Complete; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberScheduled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EnrichPolicyPhase.Scheduled; + } + + if (string.Equals(value, MemberRunning.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EnrichPolicyPhase.Running; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EnrichPolicyPhase.Failed; + } + + if (string.Equals(value, MemberComplete.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override EnrichPolicyPhase ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, EnrichPolicyPhase value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -95,40 +137,73 @@ 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) + if (reader.ValueTextEquals(MemberRange)) + { + return PolicyType.Range; + } + + if (reader.ValueTextEquals(MemberMatch)) + { + return PolicyType.Match; + } + + if (reader.ValueTextEquals(MemberGeoMatch)) + { + return PolicyType.GeoMatch; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PolicyType.Range; + } + + if (string.Equals(value, MemberMatch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return PolicyType.Match; + } + + if (string.Equals(value, MemberGeoMatch.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "range": - return PolicyType.Range; - case "match": - return PolicyType.Match; - case "geo_match": - return PolicyType.GeoMatch; + return PolicyType.GeoMatch; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override PolicyType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, PolicyType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs index d4d3772640b..6f3f2d6d7bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs @@ -47,35 +47,59 @@ 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) + if (reader.ValueTextEquals(MemberTail)) + { + return ResultPosition.Tail; + } + + if (reader.ValueTextEquals(MemberHead)) { - case "tail": - return ResultPosition.Tail; - case "head": - return ResultPosition.Head; + return ResultPosition.Head; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberTail.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ResultPosition.Tail; + } + + if (string.Equals(value, MemberHead.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ResultPosition.Head; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ResultPosition ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ResultPosition value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs index 88f73b46228..e395a3a075c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs @@ -49,65 +49,143 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + 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)) + { + return EsqlFormat.Smile; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYaml.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Yaml; + } + + if (string.Equals(value, MemberTxt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Txt; + } + + if (string.Equals(value, MemberTsv.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Tsv; + } + + if (string.Equals(value, MemberSmile.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Smile; + } + + if (string.Equals(value, MemberJson.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Json; + } + + if (string.Equals(value, MemberCsv.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Csv; + } + + if (string.Equals(value, MemberCbor.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Cbor; + } + + if (string.Equals(value, MemberArrow.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EsqlFormat.Arrow; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override EsqlFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, EsqlFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs index a5fbdb62bbf..83da75298d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs @@ -39,41 +39,74 @@ 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) + if (reader.ValueTextEquals(MemberSettings)) + { + return Feature.Settings; + } + + if (reader.ValueTextEquals(MemberMappings)) + { + return Feature.Mappings; + } + + if (reader.ValueTextEquals(MemberAliases)) + { + return Feature.Aliases; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSettings.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "settings": - return Feature.Settings; - case "mappings": - return Feature.Mappings; - case "aliases": - return Feature.Aliases; + return Feature.Settings; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberMappings.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Feature.Mappings; + } + + if (string.Equals(value, MemberAliases.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Feature.Aliases; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override Feature ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Feature value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -88,41 +121,79 @@ 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) + if (reader.ValueTextEquals(MemberTrue)) + { + return IndexCheckOnStartup.True; + } + + if (reader.ValueTextEquals(MemberFalse)) + { + return IndexCheckOnStartup.False; + } + + if (reader.ValueTextEquals(MemberChecksum)) + { + return IndexCheckOnStartup.Checksum; + } + + if (reader.TokenType is not System.Text.Json.JsonTokenType.String) + { + throw new System.Text.Json.JsonException($"Unknown member of type '{reader.TokenType}' for enum '{nameof(IndexCheckOnStartup)}'."); + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTrue.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexCheckOnStartup.True; + } + + if (string.Equals(value, MemberFalse.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "true": - return IndexCheckOnStartup.True; - case "false": - return IndexCheckOnStartup.False; - case "checksum": - return IndexCheckOnStartup.Checksum; + return IndexCheckOnStartup.False; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberChecksum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexCheckOnStartup.Checksum; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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.WriteRawValue(MemberTrue.EncodedUtf8Bytes); + break; case IndexCheckOnStartup.False: - writer.WriteStringValue("false"); - return; + writer.WriteRawValue(MemberFalse.EncodedUtf8Bytes); + 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(); + public override IndexCheckOnStartup ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexCheckOnStartup value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -135,36 +206,60 @@ 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) + if (reader.ValueTextEquals(MemberOpen)) + { + return IndexMetadataState.Open; + } + + if (reader.ValueTextEquals(MemberClose)) + { + return IndexMetadataState.Close; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberOpen.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexMetadataState.Open; + } + + if (string.Equals(value, MemberClose.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "open": - return IndexMetadataState.Open; - case "close": - return IndexMetadataState.Close; + return IndexMetadataState.Close; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override IndexMetadataState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexMetadataState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -181,46 +276,88 @@ 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) + if (reader.ValueTextEquals(MemberPrimaries)) + { + return IndexRoutingAllocationOptions.Primaries; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return IndexRoutingAllocationOptions.None; + } + + if (reader.ValueTextEquals(MemberNewPrimaries)) + { + return IndexRoutingAllocationOptions.NewPrimaries; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return IndexRoutingAllocationOptions.All; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPrimaries.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingAllocationOptions.Primaries; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingAllocationOptions.None; + } + + if (string.Equals(value, MemberNewPrimaries.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingAllocationOptions.NewPrimaries; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "primaries": - return IndexRoutingAllocationOptions.Primaries; - case "none": - return IndexRoutingAllocationOptions.None; - case "new_primaries": - return IndexRoutingAllocationOptions.NewPrimaries; - case "all": - return IndexRoutingAllocationOptions.All; + return IndexRoutingAllocationOptions.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override IndexRoutingAllocationOptions ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexRoutingAllocationOptions value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -237,46 +374,88 @@ 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) + if (reader.ValueTextEquals(MemberReplicas)) + { + return IndexRoutingRebalanceOptions.Replicas; + } + + if (reader.ValueTextEquals(MemberPrimaries)) + { + return IndexRoutingRebalanceOptions.Primaries; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return IndexRoutingRebalanceOptions.None; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return IndexRoutingRebalanceOptions.All; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberReplicas.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingRebalanceOptions.Replicas; + } + + if (string.Equals(value, MemberPrimaries.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingRebalanceOptions.Primaries; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexRoutingRebalanceOptions.None; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "replicas": - return IndexRoutingRebalanceOptions.Replicas; - case "primaries": - return IndexRoutingRebalanceOptions.Primaries; - case "none": - return IndexRoutingRebalanceOptions.None; - case "all": - return IndexRoutingRebalanceOptions.All; + return IndexRoutingRebalanceOptions.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override IndexRoutingRebalanceOptions ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexRoutingRebalanceOptions value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -291,41 +470,74 @@ 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) + if (reader.ValueTextEquals(MemberUnmanaged)) + { + return ManagedBy.Unmanaged; + } + + if (reader.ValueTextEquals(MemberIlm)) + { + return ManagedBy.Ilm; + } + + if (reader.ValueTextEquals(MemberDatastream)) + { + return ManagedBy.Datastream; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUnmanaged.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ManagedBy.Unmanaged; + } + + if (string.Equals(value, MemberIlm.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "Unmanaged": - return ManagedBy.Unmanaged; - case "Index Lifecycle Management": - return ManagedBy.Ilm; - case "Data stream lifecycle": - return ManagedBy.Datastream; + return ManagedBy.Ilm; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberDatastream.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ManagedBy.Datastream; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ManagedBy ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ManagedBy value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -338,36 +550,60 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberDisabled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NumericFielddataFormat.Disabled; + } + + if (string.Equals(value, MemberArray.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NumericFielddataFormat.Array; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override NumericFielddataFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, NumericFielddataFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -380,36 +616,60 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberLast.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SegmentSortMissing.Last; + } + + if (string.Equals(value, MemberFirst.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SegmentSortMissing.First; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SegmentSortMissing ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SegmentSortMissing value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -422,38 +682,62 @@ 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) + if (reader.ValueTextEquals(MemberMin) || reader.ValueTextEquals(MemberMin1)) + { + return SegmentSortMode.Min; + } + + if (reader.ValueTextEquals(MemberMax) || reader.ValueTextEquals(MemberMax1)) + { + return SegmentSortMode.Max; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberMin1.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "min": - case "MIN": - return SegmentSortMode.Min; - case "max": - case "MAX": - return SegmentSortMode.Max; + return SegmentSortMode.Min; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberMax1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SegmentSortMode.Max; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SegmentSortMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SegmentSortMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -466,38 +750,62 @@ 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) + if (reader.ValueTextEquals(MemberDesc) || reader.ValueTextEquals(MemberDesc1)) + { + return SegmentSortOrder.Desc; + } + + if (reader.ValueTextEquals(MemberAsc) || reader.ValueTextEquals(MemberAsc1)) + { + return SegmentSortOrder.Asc; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberDesc.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberDesc1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SegmentSortOrder.Desc; + } + + if (string.Equals(value, MemberAsc.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberAsc1.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "desc": - case "DESC": - return SegmentSortOrder.Desc; - case "asc": - case "ASC": - return SegmentSortOrder.Asc; + return SegmentSortOrder.Asc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SegmentSortOrder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SegmentSortOrder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -514,46 +822,88 @@ 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) + if (reader.ValueTextEquals(MemberUnassigned)) + { + return ShardRoutingState.Unassigned; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return ShardRoutingState.Started; + } + + if (reader.ValueTextEquals(MemberRelocating)) + { + return ShardRoutingState.Relocating; + } + + if (reader.ValueTextEquals(MemberInitializing)) + { + return ShardRoutingState.Initializing; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUnassigned.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "UNASSIGNED": - return ShardRoutingState.Unassigned; - case "STARTED": - return ShardRoutingState.Started; - case "RELOCATING": - return ShardRoutingState.Relocating; - case "INITIALIZING": - return ShardRoutingState.Initializing; + return ShardRoutingState.Unassigned; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardRoutingState.Started; + } + + if (string.Equals(value, MemberRelocating.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardRoutingState.Relocating; + } + + if (string.Equals(value, MemberInitializing.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardRoutingState.Initializing; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ShardRoutingState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ShardRoutingState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -568,41 +918,74 @@ public enum ShardStoreAllocation Primary } -internal sealed class ShardStoreAllocationConverter : JsonConverter +internal sealed partial class ShardStoreAllocationConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStoreAllocation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnused = System.Text.Json.JsonEncodedText.Encode("unused"); + private static readonly System.Text.Json.JsonEncodedText MemberReplica = System.Text.Json.JsonEncodedText.Encode("replica"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + + public override ShardStoreAllocation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberUnused)) + { + return ShardStoreAllocation.Unused; + } + + if (reader.ValueTextEquals(MemberReplica)) + { + return ShardStoreAllocation.Replica; + } + + if (reader.ValueTextEquals(MemberPrimary)) + { + return ShardStoreAllocation.Primary; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUnused.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreAllocation.Unused; + } + + if (string.Equals(value, MemberReplica.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "unused": - return ShardStoreAllocation.Unused; - case "replica": - return ShardStoreAllocation.Replica; - case "primary": - return ShardStoreAllocation.Primary; + return ShardStoreAllocation.Replica; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberPrimary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreAllocation.Primary; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(ShardStoreAllocation)}'."); } - public override void Write(Utf8JsonWriter writer, ShardStoreAllocation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoreAllocation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardStoreAllocation.Unused: - writer.WriteStringValue("unused"); - return; + writer.WriteStringValue(MemberUnused); + break; case ShardStoreAllocation.Replica: - writer.WriteStringValue("replica"); - return; + writer.WriteStringValue(MemberReplica); + break; case ShardStoreAllocation.Primary: - writer.WriteStringValue("primary"); - return; + writer.WriteStringValue(MemberPrimary); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardStoreAllocation)}'."); } + } - writer.WriteNullValue(); + public override ShardStoreAllocation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ShardStoreAllocation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -639,46 +1022,88 @@ public enum ShardStoreStatus All } -internal sealed class ShardStoreStatusConverter : JsonConverter +internal sealed partial class ShardStoreStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStoreStatus 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 MemberRed = 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 MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ShardStoreStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberYellow)) { - case "yellow": - return ShardStoreStatus.Yellow; - case "red": - return ShardStoreStatus.Red; - case "green": - return ShardStoreStatus.Green; - case "all": - return ShardStoreStatus.All; + return ShardStoreStatus.Yellow; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRed)) + { + return ShardStoreStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen)) + { + return ShardStoreStatus.Green; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ShardStoreStatus.All; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYellow.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreStatus.Yellow; + } + + if (string.Equals(value, MemberRed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreStatus.Red; + } + + if (string.Equals(value, MemberGreen.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreStatus.Green; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardStoreStatus.All; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(ShardStoreStatus)}'."); } - public override void Write(Utf8JsonWriter writer, ShardStoreStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoreStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardStoreStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case ShardStoreStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case ShardStoreStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; case ShardStoreStatus.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardStoreStatus)}'."); } + } - writer.WriteNullValue(); + public override ShardStoreStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ShardStoreStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -686,9 +1111,11 @@ public override void Write(Utf8JsonWriter writer, ShardStoreStatus value, JsonSe 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; } /// @@ -761,37 +1188,61 @@ 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) + if (reader.ValueTextEquals(MemberRequest) || reader.ValueTextEquals(MemberRequest1)) + { + return TranslogDurability.Request; + } + + if (reader.ValueTextEquals(MemberAsync) || reader.ValueTextEquals(MemberAsync1)) + { + return TranslogDurability.Async; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRequest.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberRequest1.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "request": - case "REQUEST": - return TranslogDurability.Request; - case "async": - case "ASYNC": - return TranslogDurability.Async; + return TranslogDurability.Request; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberAsync.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberAsync1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TranslogDurability.Async; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TranslogDurability ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TranslogDurability value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs index ab0a177455b..35a36dcf298 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs @@ -41,45 +41,87 @@ 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) + if (reader.ValueTextEquals(MemberTextEmbedding)) + { + return TaskType.TextEmbedding; + } + + if (reader.ValueTextEquals(MemberSparseEmbedding)) + { + return TaskType.SparseEmbedding; + } + + if (reader.ValueTextEquals(MemberRerank)) { - case "text_embedding": - return TaskType.TextEmbedding; - case "sparse_embedding": - return TaskType.SparseEmbedding; - case "rerank": - return TaskType.Rerank; - case "completion": - return TaskType.Completion; + return TaskType.Rerank; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCompletion)) + { + return TaskType.Completion; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTextEmbedding.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TaskType.TextEmbedding; + } + + if (string.Equals(value, MemberSparseEmbedding.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TaskType.SparseEmbedding; + } + + if (string.Equals(value, MemberRerank.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TaskType.Rerank; + } + + if (string.Equals(value, MemberCompletion.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TaskType.Completion; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override TaskType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TaskType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs index 6e2a0890436..13c383dd8de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs @@ -49,66 +49,144 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberString.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.String; + } + + if (string.Equals(value, MemberLong.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Long; + } + + if (string.Equals(value, MemberIp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Ip; + } + + if (string.Equals(value, MemberInteger.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Integer; + } + + if (string.Equals(value, MemberFloat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Float; + } + + if (string.Equals(value, MemberDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Double; + } + + if (string.Equals(value, MemberBoolean.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Boolean; + } + + if (string.Equals(value, MemberAuto.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConvertType.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ConvertType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ConvertType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -127,51 +205,102 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSha512.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FingerprintDigest.Sha512; + } + + if (string.Equals(value, MemberSha256.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FingerprintDigest.Sha256; + } + + if (string.Equals(value, MemberSha1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FingerprintDigest.Sha1; + } + + if (string.Equals(value, MemberMurmurhash3.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FingerprintDigest.Murmurhash3; + } + + if (string.Equals(value, MemberMd5.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FingerprintDigest.Md5; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override FingerprintDigest ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FingerprintDigest value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -184,36 +313,60 @@ 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) + if (reader.ValueTextEquals(MemberWkt)) + { + return GeoGridTargetFormat.Wkt; + } + + if (reader.ValueTextEquals(MemberGeojson)) + { + return GeoGridTargetFormat.Geojson; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWkt.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "wkt": - return GeoGridTargetFormat.Wkt; - case "geojson": - return GeoGridTargetFormat.Geojson; + return GeoGridTargetFormat.Wkt; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberGeojson.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoGridTargetFormat.Geojson; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override GeoGridTargetFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoGridTargetFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -228,41 +381,74 @@ 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) + if (reader.ValueTextEquals(MemberGeotile)) + { + return GeoGridTileType.Geotile; + } + + if (reader.ValueTextEquals(MemberGeohex)) + { + return GeoGridTileType.Geohex; + } + + if (reader.ValueTextEquals(MemberGeohash)) + { + return GeoGridTileType.Geohash; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberGeotile.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoGridTileType.Geotile; + } + + if (string.Equals(value, MemberGeohex.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoGridTileType.Geohex; + } + + if (string.Equals(value, MemberGeohash.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "geotile": - return GeoGridTileType.Geotile; - case "geohex": - return GeoGridTileType.Geohex; - case "geohash": - return GeoGridTileType.Geohash; + return GeoGridTileType.Geohash; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override GeoGridTileType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoGridTileType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -285,36 +471,60 @@ 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) + if (reader.ValueTextEquals(MemberReplace)) + { + return JsonProcessorConflictStrategy.Replace; + } + + if (reader.ValueTextEquals(MemberMerge)) + { + return JsonProcessorConflictStrategy.Merge; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberReplace.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "replace": - return JsonProcessorConflictStrategy.Replace; - case "merge": - return JsonProcessorConflictStrategy.Merge; + return JsonProcessorConflictStrategy.Replace; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberMerge.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JsonProcessorConflictStrategy.Merge; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override JsonProcessorConflictStrategy ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, JsonProcessorConflictStrategy value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -327,36 +537,60 @@ 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) + if (reader.ValueTextEquals(MemberShape)) + { + return ShapeType.Shape; + } + + if (reader.ValueTextEquals(MemberGeoShape)) { - case "shape": - return ShapeType.Shape; - case "geo_shape": - return ShapeType.GeoShape; + return ShapeType.GeoShape; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberShape.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShapeType.Shape; + } + + if (string.Equals(value, MemberGeoShape.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShapeType.GeoShape; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ShapeType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ShapeType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -375,50 +609,101 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberVersion.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UserAgentProperty.Version; + } + + if (string.Equals(value, MemberOs.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UserAgentProperty.Os; + } + + if (string.Equals(value, MemberOriginal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UserAgentProperty.Original; + } + + if (string.Equals(value, MemberName.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UserAgentProperty.Name; + } + + if (string.Equals(value, MemberDevice.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return UserAgentProperty.Device; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override UserAgentProperty ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, UserAgentProperty value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs index 00f97d8b1e7..d4a9cadbc4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs @@ -41,46 +41,88 @@ 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) + 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)) + { + return LicenseStatus.Active; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberValid.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseStatus.Valid; + } + + if (string.Equals(value, MemberInvalid.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseStatus.Invalid; + } + + if (string.Equals(value, MemberExpired.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseStatus.Expired; + } + + if (string.Equals(value, MemberActive.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override LicenseStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, LicenseStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -107,70 +149,157 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberTrial)) + { + return LicenseType.Trial; + } + + if (reader.ValueTextEquals(MemberStandard)) + { + return LicenseType.Standard; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTrial.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Trial; + } + + if (string.Equals(value, MemberStandard.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Standard; + } + + if (string.Equals(value, MemberSilver.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Silver; + } + + if (string.Equals(value, MemberPlatinum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Platinum; + } + + if (string.Equals(value, MemberMissing.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Missing; + } + + if (string.Equals(value, MemberGold.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Gold; + } + + if (string.Equals(value, MemberEnterprise.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Enterprise; + } + + if (string.Equals(value, MemberDev.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Dev; + } + + if (string.Equals(value, MemberBasic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LicenseType.Basic; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override LicenseType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, LicenseType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs index a9f89e68101..e17a2d7fce4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs @@ -41,46 +41,88 @@ 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) + if (reader.ValueTextEquals(MemberTypical)) + { + return AppliesTo.Typical; + } + + if (reader.ValueTextEquals(MemberTime)) + { + return AppliesTo.Time; + } + + if (reader.ValueTextEquals(MemberDiffFromTypical)) + { + return AppliesTo.DiffFromTypical; + } + + if (reader.ValueTextEquals(MemberActual)) + { + return AppliesTo.Actual; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTypical.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AppliesTo.Typical; + } + + if (string.Equals(value, MemberTime.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AppliesTo.Time; + } + + if (string.Equals(value, MemberDiffFromTypical.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 (string.Equals(value, MemberActual.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AppliesTo.Actual; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override AppliesTo ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, AppliesTo value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -93,36 +135,60 @@ 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) + if (reader.ValueTextEquals(MemberWarn)) + { + return CategorizationStatus.Warn; + } + + if (reader.ValueTextEquals(MemberOk)) + { + return CategorizationStatus.Ok; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWarn.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "warn": - return CategorizationStatus.Warn; - case "ok": - return CategorizationStatus.Ok; + return CategorizationStatus.Warn; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberOk.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CategorizationStatus.Ok; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override CategorizationStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, CategorizationStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -137,41 +203,74 @@ 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) + if (reader.ValueTextEquals(MemberOff)) + { + return ChunkingMode.Off; + } + + if (reader.ValueTextEquals(MemberManual)) + { + return ChunkingMode.Manual; + } + + if (reader.ValueTextEquals(MemberAuto)) { - case "off": - return ChunkingMode.Off; - case "manual": - return ChunkingMode.Manual; - case "auto": - return ChunkingMode.Auto; + return ChunkingMode.Auto; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberOff.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChunkingMode.Off; + } + + if (string.Equals(value, MemberManual.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChunkingMode.Manual; + } + + if (string.Equals(value, MemberAuto.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChunkingMode.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ChunkingMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ChunkingMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -188,46 +287,88 @@ 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) + if (reader.ValueTextEquals(MemberLte)) + { + return ConditionOperator.Lte; + } + + if (reader.ValueTextEquals(MemberLt)) + { + return ConditionOperator.Lt; + } + + if (reader.ValueTextEquals(MemberGte)) + { + return ConditionOperator.Gte; + } + + if (reader.ValueTextEquals(MemberGt)) + { + return ConditionOperator.Gt; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberLte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConditionOperator.Lte; + } + + if (string.Equals(value, MemberLt.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "lte": - return ConditionOperator.Lte; - case "lt": - return ConditionOperator.Lt; - case "gte": - return ConditionOperator.Gte; - case "gt": - return ConditionOperator.Gt; + return ConditionOperator.Lt; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberGte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConditionOperator.Gte; + } + + if (string.Equals(value, MemberGt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ConditionOperator.Gt; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ConditionOperator ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ConditionOperator value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -244,46 +385,88 @@ 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) + if (reader.ValueTextEquals(MemberStopping)) + { + return DatafeedState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return DatafeedState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DatafeedState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DatafeedState.Started; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DatafeedState.Stopping; + } + + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DatafeedState.Stopped; + } + + if (string.Equals(value, MemberStarting.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "stopping": - return DatafeedState.Stopping; - case "stopped": - return DatafeedState.Stopped; - case "starting": - return DatafeedState.Starting; - case "started": - return DatafeedState.Started; + return DatafeedState.Starting; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DatafeedState.Started; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override DatafeedState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DatafeedState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -302,51 +485,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DataframeState.Stopping; + } + + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DataframeState.Stopped; + } + + if (string.Equals(value, MemberStarting.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return DataframeState.Starting; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DataframeState.Started; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DataframeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override DataframeState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DataframeState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -376,41 +610,74 @@ 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) + if (reader.ValueTextEquals(MemberStarting)) + { + return DeploymentAllocationState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DeploymentAllocationState.Started; + } + + if (reader.ValueTextEquals(MemberFullyAllocated)) + { + return DeploymentAllocationState.FullyAllocated; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStarting.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DeploymentAllocationState.Starting; + } + + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DeploymentAllocationState.Started; + } + + if (string.Equals(value, MemberFullyAllocated.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "starting": - return DeploymentAllocationState.Starting; - case "started": - return DeploymentAllocationState.Started; - case "fully_allocated": - return DeploymentAllocationState.FullyAllocated; + return DeploymentAllocationState.FullyAllocated; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DeploymentAllocationState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DeploymentAllocationState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -447,46 +714,88 @@ 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) + if (reader.ValueTextEquals(MemberStopping)) + { + return DeploymentAssignmentState.Stopping; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DeploymentAssignmentState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DeploymentAssignmentState.Started; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return DeploymentAssignmentState.Failed; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "stopping": - return DeploymentAssignmentState.Stopping; - case "starting": - return DeploymentAssignmentState.Starting; - case "started": - return DeploymentAssignmentState.Started; - case "failed": - return DeploymentAssignmentState.Failed; + return DeploymentAssignmentState.Stopping; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberStarting.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DeploymentAssignmentState.Starting; + } + + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DeploymentAssignmentState.Started; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DeploymentAssignmentState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DeploymentAssignmentState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DeploymentAssignmentState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -503,46 +812,88 @@ 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) + if (reader.ValueTextEquals(MemberOver)) + { + return ExcludeFrequent.Over; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ExcludeFrequent.None; + } + + if (reader.ValueTextEquals(MemberBy)) + { + return ExcludeFrequent.By; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ExcludeFrequent.All; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberOver.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExcludeFrequent.Over; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "over": - return ExcludeFrequent.Over; - case "none": - return ExcludeFrequent.None; - case "by": - return ExcludeFrequent.By; - case "all": - return ExcludeFrequent.All; + return ExcludeFrequent.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberBy.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExcludeFrequent.By; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExcludeFrequent.All; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ExcludeFrequent ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ExcludeFrequent value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -555,36 +906,60 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberInclude.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FilterType.Include; + } + + if (string.Equals(value, MemberExclude.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FilterType.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override FilterType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FilterType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -633,51 +1008,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTotalFeatureImportance.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Include.TotalFeatureImportance; + } + + if (string.Equals(value, MemberHyperparameters.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return Include.Hyperparameters; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberFeatureImportanceBaseline.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Include.FeatureImportanceBaseline; + } + + if (string.Equals(value, MemberDefinitionStatus.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Include.DefinitionStatus; + } + + if (string.Equals(value, MemberDefinition.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Include.Definition; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override Include ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Include value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -692,41 +1118,74 @@ 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) + if (reader.ValueTextEquals(MemberRevert)) + { + return JobBlockedReason.Revert; + } + + if (reader.ValueTextEquals(MemberReset)) + { + return JobBlockedReason.Reset; + } + + if (reader.ValueTextEquals(MemberDelete)) + { + return JobBlockedReason.Delete; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRevert.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobBlockedReason.Revert; + } + + if (string.Equals(value, MemberReset.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobBlockedReason.Reset; + } + + if (string.Equals(value, MemberDelete.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "revert": - return JobBlockedReason.Revert; - case "reset": - return JobBlockedReason.Reset; - case "delete": - return JobBlockedReason.Delete; + return JobBlockedReason.Delete; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override JobBlockedReason ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, JobBlockedReason value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -773,51 +1232,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberOpening.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobState.Opening; + } + + if (string.Equals(value, MemberOpened.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobState.Opened; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobState.Failed; + } + + if (string.Equals(value, MemberClosing.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return JobState.Closing; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberClosed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return JobState.Closed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override JobState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, JobState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -832,41 +1342,74 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberSoftLimit.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MemoryStatus.SoftLimit; + } + + if (string.Equals(value, MemberOk.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MemoryStatus.Ok; + } + + if (string.Equals(value, MemberHardLimit.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MemoryStatus.HardLimit; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override MemoryStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MemoryStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -910,51 +1453,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RoutingState.Stopping; + } + + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RoutingState.Stopped; + } + + if (string.Equals(value, MemberStarting.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RoutingState.Starting; + } + + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RoutingState.Started; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return RoutingState.Failed; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override RoutingState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RoutingState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -977,36 +1571,60 @@ 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) + if (reader.ValueTextEquals(MemberSkipResult)) + { + return RuleAction.SkipResult; + } + + if (reader.ValueTextEquals(MemberSkipModelUpdate)) + { + return RuleAction.SkipModelUpdate; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSkipResult.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuleAction.SkipResult; + } + + if (string.Equals(value, MemberSkipModelUpdate.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override RuleAction ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RuleAction value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1023,46 +1641,88 @@ 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) + if (reader.ValueTextEquals(MemberStopped)) + { + return SnapshotUpgradeState.Stopped; + } + + if (reader.ValueTextEquals(MemberSavingNewState)) + { + return SnapshotUpgradeState.SavingNewState; + } + + if (reader.ValueTextEquals(MemberLoadingOldState)) + { + return SnapshotUpgradeState.LoadingOldState; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return SnapshotUpgradeState.Failed; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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.Stopped; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberSavingNewState.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotUpgradeState.SavingNewState; + } + + if (string.Equals(value, MemberLoadingOldState.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotUpgradeState.LoadingOldState; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotUpgradeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SnapshotUpgradeState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SnapshotUpgradeState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1077,41 +1737,74 @@ 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) + if (reader.ValueTextEquals(MemberSecond)) + { + return TokenizationTruncate.Second; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return TokenizationTruncate.None; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return TokenizationTruncate.First; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSecond.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenizationTruncate.Second; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TokenizationTruncate.None; + } + + if (string.Equals(value, MemberFirst.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "second": - return TokenizationTruncate.Second; - case "none": - return TokenizationTruncate.None; - case "first": - return TokenizationTruncate.First; + return TokenizationTruncate.First; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TokenizationTruncate ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TokenizationTruncate value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1142,41 +1835,74 @@ 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) + if (reader.ValueTextEquals(MemberTreeEnsemble)) + { + return TrainedModelType.TreeEnsemble; + } + + if (reader.ValueTextEquals(MemberPytorch)) + { + return TrainedModelType.Pytorch; + } + + if (reader.ValueTextEquals(MemberLangIdent)) + { + return TrainedModelType.LangIdent; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTreeEnsemble.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 (string.Equals(value, MemberPytorch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TrainedModelType.Pytorch; + } + + if (string.Equals(value, MemberLangIdent.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TrainedModelType.LangIdent; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TrainedModelType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TrainedModelType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1189,35 +1915,59 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberNormal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TrainingPriority.Normal; + } + + if (string.Equals(value, MemberLow.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TrainingPriority.Low; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TrainingPriority ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TrainingPriority value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs index af9e0d808bf..9a5473a9e2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs @@ -58,41 +58,74 @@ 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) + if (reader.ValueTextEquals(MemberFloat)) + { + return DenseVectorElementType.Float; + } + + if (reader.ValueTextEquals(MemberByte)) + { + return DenseVectorElementType.Byte; + } + + if (reader.ValueTextEquals(MemberBit)) + { + return DenseVectorElementType.Bit; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberFloat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorElementType.Float; + } + + if (string.Equals(value, MemberByte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorElementType.Byte; + } + + if (string.Equals(value, MemberBit.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override DenseVectorElementType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DenseVectorElementType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -153,56 +186,116 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberInt8Hnsw.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Int8Hnsw; + } + + if (string.Equals(value, MemberInt8Flat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Int8Flat; + } + + if (string.Equals(value, MemberInt4Hnsw.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Int4Hnsw; + } + + if (string.Equals(value, MemberInt4Flat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Int4Flat; + } + + if (string.Equals(value, MemberHnsw.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Hnsw; + } + + if (string.Equals(value, MemberFlat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorIndexOptionsType.Flat; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DenseVectorIndexOptionsType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DenseVectorIndexOptionsType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -277,46 +370,88 @@ 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) + if (reader.ValueTextEquals(MemberMaxInnerProduct)) + { + return DenseVectorSimilarity.MaxInnerProduct; + } + + if (reader.ValueTextEquals(MemberL2Norm)) + { + return DenseVectorSimilarity.L2Norm; + } + + if (reader.ValueTextEquals(MemberDotProduct)) + { + return DenseVectorSimilarity.DotProduct; + } + + if (reader.ValueTextEquals(MemberCosine)) + { + return DenseVectorSimilarity.Cosine; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberMaxInnerProduct.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorSimilarity.MaxInnerProduct; + } + + if (string.Equals(value, MemberL2Norm.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorSimilarity.L2Norm; + } + + if (string.Equals(value, MemberDotProduct.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DenseVectorSimilarity.DotProduct; + } + + if (string.Equals(value, MemberCosine.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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.Cosine; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DenseVectorSimilarity ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DenseVectorSimilarity value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -333,46 +468,93 @@ 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) + if (reader.ValueTextEquals(MemberTrue)) + { + return DynamicMapping.True; + } + + if (reader.ValueTextEquals(MemberStrict)) + { + return DynamicMapping.Strict; + } + + if (reader.ValueTextEquals(MemberRuntime)) { - case "true": - return DynamicMapping.True; - case "strict": - return DynamicMapping.Strict; - case "runtime": - return DynamicMapping.Runtime; - case "false": - return DynamicMapping.False; + return DynamicMapping.Runtime; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFalse)) + { + return DynamicMapping.False; + } + + if (reader.TokenType is not System.Text.Json.JsonTokenType.String) + { + throw new System.Text.Json.JsonException($"Unknown member of type '{reader.TokenType}' for enum '{nameof(DynamicMapping)}'."); + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTrue.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DynamicMapping.True; + } + + if (string.Equals(value, MemberStrict.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DynamicMapping.Strict; + } + + if (string.Equals(value, MemberRuntime.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DynamicMapping.Runtime; + } + + if (string.Equals(value, MemberFalse.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DynamicMapping.False; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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.WriteRawValue(MemberTrue.EncodedUtf8Bytes); + 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.WriteRawValue(MemberFalse.EncodedUtf8Bytes); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DynamicMapping)}'."); } + } + + public override DynamicMapping ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DynamicMapping value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -475,449 +657,992 @@ 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; - } + if (reader.ValueTextEquals(MemberVersion)) + { + return FieldType.Version; + } - public override void Write(Utf8JsonWriter writer, FieldType value, JsonSerializerOptions options) - { - switch (value) + if (reader.ValueTextEquals(MemberTokenCount)) { - case FieldType.Version: - writer.WriteStringValue("version"); - return; - case FieldType.TokenCount: - writer.WriteStringValue("token_count"); - return; - case FieldType.Text: - writer.WriteStringValue("text"); - return; - case FieldType.SparseVector: - writer.WriteStringValue("sparse_vector"); - return; - case FieldType.Short: - writer.WriteStringValue("short"); - return; - case FieldType.Shape: - writer.WriteStringValue("shape"); - return; - case FieldType.SemanticText: - writer.WriteStringValue("semantic_text"); - return; - case FieldType.SearchAsYouType: - writer.WriteStringValue("search_as_you_type"); - return; - case FieldType.ScaledFloat: - writer.WriteStringValue("scaled_float"); - return; - case FieldType.RankFeatures: - writer.WriteStringValue("rank_features"); - return; - case FieldType.RankFeature: - writer.WriteStringValue("rank_feature"); - return; - case FieldType.Percolator: - writer.WriteStringValue("percolator"); - return; - case FieldType.Passthrough: - writer.WriteStringValue("passthrough"); - return; - case FieldType.Object: - writer.WriteStringValue("object"); - return; - case FieldType.None: - writer.WriteStringValue("none"); - return; - case FieldType.Nested: - writer.WriteStringValue("nested"); - return; - case FieldType.Murmur3: - writer.WriteStringValue("murmur3"); - return; - case FieldType.MatchOnlyText: - writer.WriteStringValue("match_only_text"); - return; - case FieldType.LongRange: - writer.WriteStringValue("long_range"); - return; - case FieldType.Long: - writer.WriteStringValue("long"); - return; - case FieldType.Keyword: - writer.WriteStringValue("keyword"); - return; - case FieldType.Join: - writer.WriteStringValue("join"); - return; - case FieldType.IpRange: - writer.WriteStringValue("ip_range"); - return; - case FieldType.Ip: - writer.WriteStringValue("ip"); - return; - case FieldType.IntegerRange: - writer.WriteStringValue("integer_range"); - return; - case FieldType.Integer: - writer.WriteStringValue("integer"); - return; - case FieldType.IcuCollationKeyword: - writer.WriteStringValue("icu_collation_keyword"); - return; - case FieldType.Histogram: - writer.WriteStringValue("histogram"); - return; - case FieldType.HalfFloat: - writer.WriteStringValue("half_float"); - return; - case FieldType.GeoShape: - writer.WriteStringValue("geo_shape"); - return; - case FieldType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; - case FieldType.FloatRange: - writer.WriteStringValue("float_range"); - return; - case FieldType.Float: - writer.WriteStringValue("float"); - return; - case FieldType.Flattened: - writer.WriteStringValue("flattened"); - return; - case FieldType.DoubleRange: - writer.WriteStringValue("double_range"); - return; - case FieldType.Double: - writer.WriteStringValue("double"); - return; - case FieldType.DenseVector: - writer.WriteStringValue("dense_vector"); - return; - case FieldType.DateRange: - writer.WriteStringValue("date_range"); - return; - case FieldType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; - case FieldType.Date: - writer.WriteStringValue("date"); - return; - case FieldType.ConstantKeyword: - writer.WriteStringValue("constant_keyword"); - return; - case FieldType.Completion: - writer.WriteStringValue("completion"); - return; - case FieldType.Byte: - writer.WriteStringValue("byte"); - return; - case FieldType.Boolean: - writer.WriteStringValue("boolean"); - return; - case FieldType.Binary: - writer.WriteStringValue("binary"); - return; - case FieldType.Alias: - writer.WriteStringValue("alias"); - return; - case FieldType.AggregateMetricDouble: - writer.WriteStringValue("aggregate_metric_double"); - return; + return FieldType.TokenCount; } - writer.WriteNullValue(); - } -} + if (reader.ValueTextEquals(MemberText)) + { + return FieldType.Text; + } -[JsonConverter(typeof(GeoOrientationConverter))] -public enum GeoOrientation -{ - [EnumMember(Value = "right")] - Right, - [EnumMember(Value = "left")] - Left -} + if (reader.ValueTextEquals(MemberSparseVector)) + { + return FieldType.SparseVector; + } -internal sealed class GeoOrientationConverter : JsonConverter -{ - public override GeoOrientation Read(ref Utf8JsonReader reader, Type typeToConvert, 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; - } + if (reader.ValueTextEquals(MemberShort)) + { + return FieldType.Short; + } - public override void Write(Utf8JsonWriter writer, GeoOrientation value, JsonSerializerOptions options) - { - switch (value) + if (reader.ValueTextEquals(MemberShape)) { - case GeoOrientation.Right: - writer.WriteStringValue("right"); - return; - case GeoOrientation.Left: - writer.WriteStringValue("left"); - return; + return FieldType.Shape; } - writer.WriteNullValue(); - } -} + if (reader.ValueTextEquals(MemberSemanticText)) + { + return FieldType.SemanticText; + } -[JsonConverter(typeof(GeoStrategyConverter))] -public enum GeoStrategy -{ - [EnumMember(Value = "term")] - Term, - [EnumMember(Value = "recursive")] - Recursive -} + if (reader.ValueTextEquals(MemberSearchAsYouType)) + { + return FieldType.SearchAsYouType; + } -internal sealed class GeoStrategyConverter : JsonConverter -{ - public override GeoStrategy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberScaledFloat)) { - case "term": - return GeoStrategy.Term; - case "recursive": - return GeoStrategy.Recursive; + return FieldType.ScaledFloat; } - ThrowHelper.ThrowJsonException(); - return default; - } + if (reader.ValueTextEquals(MemberRankFeatures)) + { + return FieldType.RankFeatures; + } - public override void Write(Utf8JsonWriter writer, GeoStrategy value, JsonSerializerOptions options) - { - switch (value) + if (reader.ValueTextEquals(MemberRankFeature)) { - case GeoStrategy.Term: - writer.WriteStringValue("term"); - return; - case GeoStrategy.Recursive: - writer.WriteStringValue("recursive"); - return; + return FieldType.RankFeature; } - writer.WriteNullValue(); - } -} + if (reader.ValueTextEquals(MemberPercolator)) + { + return FieldType.Percolator; + } -[JsonConverter(typeof(IndexOptionsConverter))] -public enum IndexOptions -{ - [EnumMember(Value = "positions")] - Positions, - [EnumMember(Value = "offsets")] - Offsets, - [EnumMember(Value = "freqs")] - Freqs, - [EnumMember(Value = "docs")] - Docs -} + if (reader.ValueTextEquals(MemberPassthrough)) + { + return FieldType.Passthrough; + } -internal sealed class IndexOptionsConverter : JsonConverter -{ - public override IndexOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberObject)) { - case "positions": - return IndexOptions.Positions; - case "offsets": - return IndexOptions.Offsets; - case "freqs": - return IndexOptions.Freqs; - case "docs": - return IndexOptions.Docs; + return FieldType.Object; } - ThrowHelper.ThrowJsonException(); - return default; - } + if (reader.ValueTextEquals(MemberNone)) + { + return FieldType.None; + } - public override void Write(Utf8JsonWriter writer, IndexOptions value, JsonSerializerOptions options) - { - switch (value) + if (reader.ValueTextEquals(MemberNested)) { - case IndexOptions.Positions: - writer.WriteStringValue("positions"); - return; - case IndexOptions.Offsets: - writer.WriteStringValue("offsets"); - return; - case IndexOptions.Freqs: - writer.WriteStringValue("freqs"); - return; - case IndexOptions.Docs: - writer.WriteStringValue("docs"); - return; + return FieldType.Nested; } - writer.WriteNullValue(); - } -} + if (reader.ValueTextEquals(MemberMurmur3)) + { + return FieldType.Murmur3; + } -[JsonConverter(typeof(MatchTypeConverter))] -public enum MatchType -{ - [EnumMember(Value = "simple")] - Simple, - [EnumMember(Value = "regex")] + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberVersion.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Version; + } + + if (string.Equals(value, MemberTokenCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.TokenCount; + } + + if (string.Equals(value, MemberText.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Text; + } + + if (string.Equals(value, MemberSparseVector.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.SparseVector; + } + + if (string.Equals(value, MemberShort.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Short; + } + + if (string.Equals(value, MemberShape.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Shape; + } + + if (string.Equals(value, MemberSemanticText.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.SemanticText; + } + + if (string.Equals(value, MemberSearchAsYouType.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.SearchAsYouType; + } + + if (string.Equals(value, MemberScaledFloat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.ScaledFloat; + } + + if (string.Equals(value, MemberRankFeatures.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.RankFeatures; + } + + if (string.Equals(value, MemberRankFeature.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.RankFeature; + } + + if (string.Equals(value, MemberPercolator.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Percolator; + } + + if (string.Equals(value, MemberPassthrough.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Passthrough; + } + + if (string.Equals(value, MemberObject.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Object; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.None; + } + + if (string.Equals(value, MemberNested.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Nested; + } + + if (string.Equals(value, MemberMurmur3.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Murmur3; + } + + if (string.Equals(value, MemberMatchOnlyText.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.MatchOnlyText; + } + + if (string.Equals(value, MemberLongRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.LongRange; + } + + if (string.Equals(value, MemberLong.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Long; + } + + if (string.Equals(value, MemberKeyword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Keyword; + } + + if (string.Equals(value, MemberJoin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Join; + } + + if (string.Equals(value, MemberIpRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.IpRange; + } + + if (string.Equals(value, MemberIp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Ip; + } + + if (string.Equals(value, MemberIntegerRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.IntegerRange; + } + + if (string.Equals(value, MemberInteger.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Integer; + } + + if (string.Equals(value, MemberIcuCollationKeyword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.IcuCollationKeyword; + } + + if (string.Equals(value, MemberHistogram.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Histogram; + } + + if (string.Equals(value, MemberHalfFloat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.HalfFloat; + } + + if (string.Equals(value, MemberGeoShape.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.GeoShape; + } + + if (string.Equals(value, MemberGeoPoint.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.GeoPoint; + } + + if (string.Equals(value, MemberFloatRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.FloatRange; + } + + if (string.Equals(value, MemberFloat.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Float; + } + + if (string.Equals(value, MemberFlattened.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Flattened; + } + + if (string.Equals(value, MemberDoubleRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.DoubleRange; + } + + if (string.Equals(value, MemberDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Double; + } + + if (string.Equals(value, MemberDenseVector.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.DenseVector; + } + + if (string.Equals(value, MemberDateRange.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.DateRange; + } + + if (string.Equals(value, MemberDateNanos.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.DateNanos; + } + + if (string.Equals(value, MemberDate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Date; + } + + if (string.Equals(value, MemberConstantKeyword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.ConstantKeyword; + } + + if (string.Equals(value, MemberCompletion.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Completion; + } + + if (string.Equals(value, MemberByte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Byte; + } + + if (string.Equals(value, MemberBoolean.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Boolean; + } + + if (string.Equals(value, MemberBinary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Binary; + } + + if (string.Equals(value, MemberAlias.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.Alias; + } + + if (string.Equals(value, MemberAggregateMetricDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldType.AggregateMetricDouble; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(FieldType)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldType value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case FieldType.Version: + writer.WriteStringValue(MemberVersion); + break; + case FieldType.TokenCount: + writer.WriteStringValue(MemberTokenCount); + break; + case FieldType.Text: + writer.WriteStringValue(MemberText); + break; + case FieldType.SparseVector: + writer.WriteStringValue(MemberSparseVector); + break; + case FieldType.Short: + writer.WriteStringValue(MemberShort); + break; + case FieldType.Shape: + writer.WriteStringValue(MemberShape); + break; + case FieldType.SemanticText: + writer.WriteStringValue(MemberSemanticText); + break; + case FieldType.SearchAsYouType: + writer.WriteStringValue(MemberSearchAsYouType); + break; + case FieldType.ScaledFloat: + writer.WriteStringValue(MemberScaledFloat); + break; + case FieldType.RankFeatures: + writer.WriteStringValue(MemberRankFeatures); + break; + case FieldType.RankFeature: + writer.WriteStringValue(MemberRankFeature); + break; + case FieldType.Percolator: + writer.WriteStringValue(MemberPercolator); + break; + case FieldType.Passthrough: + writer.WriteStringValue(MemberPassthrough); + break; + case FieldType.Object: + writer.WriteStringValue(MemberObject); + break; + case FieldType.None: + writer.WriteStringValue(MemberNone); + break; + case FieldType.Nested: + writer.WriteStringValue(MemberNested); + break; + case FieldType.Murmur3: + writer.WriteStringValue(MemberMurmur3); + break; + case FieldType.MatchOnlyText: + writer.WriteStringValue(MemberMatchOnlyText); + break; + case FieldType.LongRange: + writer.WriteStringValue(MemberLongRange); + break; + case FieldType.Long: + writer.WriteStringValue(MemberLong); + break; + case FieldType.Keyword: + writer.WriteStringValue(MemberKeyword); + break; + case FieldType.Join: + writer.WriteStringValue(MemberJoin); + break; + case FieldType.IpRange: + writer.WriteStringValue(MemberIpRange); + break; + case FieldType.Ip: + writer.WriteStringValue(MemberIp); + break; + case FieldType.IntegerRange: + writer.WriteStringValue(MemberIntegerRange); + break; + case FieldType.Integer: + writer.WriteStringValue(MemberInteger); + break; + case FieldType.IcuCollationKeyword: + writer.WriteStringValue(MemberIcuCollationKeyword); + break; + case FieldType.Histogram: + writer.WriteStringValue(MemberHistogram); + break; + case FieldType.HalfFloat: + writer.WriteStringValue(MemberHalfFloat); + break; + case FieldType.GeoShape: + writer.WriteStringValue(MemberGeoShape); + break; + case FieldType.GeoPoint: + writer.WriteStringValue(MemberGeoPoint); + break; + case FieldType.FloatRange: + writer.WriteStringValue(MemberFloatRange); + break; + case FieldType.Float: + writer.WriteStringValue(MemberFloat); + break; + case FieldType.Flattened: + writer.WriteStringValue(MemberFlattened); + break; + case FieldType.DoubleRange: + writer.WriteStringValue(MemberDoubleRange); + break; + case FieldType.Double: + writer.WriteStringValue(MemberDouble); + break; + case FieldType.DenseVector: + writer.WriteStringValue(MemberDenseVector); + break; + case FieldType.DateRange: + writer.WriteStringValue(MemberDateRange); + break; + case FieldType.DateNanos: + writer.WriteStringValue(MemberDateNanos); + break; + case FieldType.Date: + writer.WriteStringValue(MemberDate); + break; + case FieldType.ConstantKeyword: + writer.WriteStringValue(MemberConstantKeyword); + break; + case FieldType.Completion: + writer.WriteStringValue(MemberCompletion); + break; + case FieldType.Byte: + writer.WriteStringValue(MemberByte); + break; + case FieldType.Boolean: + writer.WriteStringValue(MemberBoolean); + break; + case FieldType.Binary: + writer.WriteStringValue(MemberBinary); + break; + case FieldType.Alias: + writer.WriteStringValue(MemberAlias); + break; + case FieldType.AggregateMetricDouble: + writer.WriteStringValue(MemberAggregateMetricDouble); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldType)}'."); + } + } + + public override FieldType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FieldType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} + +[JsonConverter(typeof(GeoOrientationConverter))] +public enum GeoOrientation +{ + [EnumMember(Value = "right")] + Right, + [EnumMember(Value = "left")] + Left +} + +internal sealed partial class GeoOrientationConverter : System.Text.Json.Serialization.JsonConverter +{ + 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRight.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberRight1.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberRight2.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberRight3.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoOrientation.Right; + } + + if (string.Equals(value, MemberLeft.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberLeft1.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberLeft2.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberLeft3.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoOrientation.Left; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(GeoOrientation)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoOrientation value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case GeoOrientation.Right: + writer.WriteStringValue(MemberRight); + break; + case GeoOrientation.Left: + writer.WriteStringValue(MemberLeft); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoOrientation)}'."); + } + } + + public override GeoOrientation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoOrientation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} + +[JsonConverter(typeof(GeoStrategyConverter))] +public enum GeoStrategy +{ + [EnumMember(Value = "term")] + Term, + [EnumMember(Value = "recursive")] + Recursive +} + +internal sealed partial class GeoStrategyConverter : System.Text.Json.Serialization.JsonConverter +{ + 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) + { + if (reader.ValueTextEquals(MemberTerm)) + { + return GeoStrategy.Term; + } + + if (reader.ValueTextEquals(MemberRecursive)) + { + return GeoStrategy.Recursive; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTerm.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoStrategy.Term; + } + + if (string.Equals(value, MemberRecursive.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoStrategy.Recursive; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(GeoStrategy)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoStrategy value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case GeoStrategy.Term: + writer.WriteStringValue(MemberTerm); + break; + case GeoStrategy.Recursive: + writer.WriteStringValue(MemberRecursive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoStrategy)}'."); + } + } + + public override GeoStrategy ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoStrategy value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} + +[JsonConverter(typeof(IndexOptionsConverter))] +public enum IndexOptions +{ + [EnumMember(Value = "positions")] + Positions, + [EnumMember(Value = "offsets")] + Offsets, + [EnumMember(Value = "freqs")] + Freqs, + [EnumMember(Value = "docs")] + Docs +} + +internal sealed partial class IndexOptionsConverter : System.Text.Json.Serialization.JsonConverter +{ + 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) + { + if (reader.ValueTextEquals(MemberPositions)) + { + return IndexOptions.Positions; + } + + if (reader.ValueTextEquals(MemberOffsets)) + { + return IndexOptions.Offsets; + } + + if (reader.ValueTextEquals(MemberFreqs)) + { + return IndexOptions.Freqs; + } + + if (reader.ValueTextEquals(MemberDocs)) + { + return IndexOptions.Docs; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPositions.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexOptions.Positions; + } + + if (string.Equals(value, MemberOffsets.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexOptions.Offsets; + } + + if (string.Equals(value, MemberFreqs.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexOptions.Freqs; + } + + if (string.Equals(value, MemberDocs.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexOptions.Docs; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(IndexOptions)}'."); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexOptions value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case IndexOptions.Positions: + writer.WriteStringValue(MemberPositions); + break; + case IndexOptions.Offsets: + writer.WriteStringValue(MemberOffsets); + break; + case IndexOptions.Freqs: + writer.WriteStringValue(MemberFreqs); + break; + case IndexOptions.Docs: + writer.WriteStringValue(MemberDocs); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexOptions)}'."); + } + } + + public override IndexOptions ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexOptions value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); + } +} + +[JsonConverter(typeof(MatchTypeConverter))] +public enum MatchType +{ + [EnumMember(Value = "simple")] + Simple, + [EnumMember(Value = "regex")] 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) + if (reader.ValueTextEquals(MemberSimple)) { - case "simple": - return MatchType.Simple; - case "regex": - return MatchType.Regex; + return MatchType.Simple; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRegex)) + { + return MatchType.Regex; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSimple.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MatchType.Simple; + } + + if (string.Equals(value, MemberRegex.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MatchType.Regex; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override MatchType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MatchType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -930,36 +1655,60 @@ 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) + if (reader.ValueTextEquals(MemberFail)) + { + return OnScriptError.Fail; + } + + if (reader.ValueTextEquals(MemberContinue)) + { + return OnScriptError.Continue; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberFail.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return OnScriptError.Fail; + } + + if (string.Equals(value, MemberContinue.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "fail": - return OnScriptError.Fail; - case "continue": - return OnScriptError.Continue; + return OnScriptError.Continue; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override OnScriptError ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, OnScriptError value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -986,71 +1735,158 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberLookup.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Lookup; + } + + if (string.Equals(value, MemberLong.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Long; + } + + if (string.Equals(value, MemberKeyword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Keyword; + } + + if (string.Equals(value, MemberIp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Ip; + } + + if (string.Equals(value, MemberGeoPoint.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.GeoPoint; + } + + if (string.Equals(value, MemberDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Double; + } + + if (string.Equals(value, MemberDate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Date; + } + + if (string.Equals(value, MemberComposite.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Composite; + } + + if (string.Equals(value, MemberBoolean.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RuntimeFieldType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override RuntimeFieldType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RuntimeFieldType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1071,41 +1907,74 @@ 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) + if (reader.ValueTextEquals(MemberSynthetic)) + { + return SourceFieldMode.Synthetic; + } + + if (reader.ValueTextEquals(MemberStored)) + { + return SourceFieldMode.Stored; + } + + if (reader.ValueTextEquals(MemberDisabled)) + { + return SourceFieldMode.Disabled; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSynthetic.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SourceFieldMode.Synthetic; + } + + if (string.Equals(value, MemberStored.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SourceFieldMode.Stored; + } + + if (string.Equals(value, MemberDisabled.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "synthetic": - return SourceFieldMode.Synthetic; - case "stored": - return SourceFieldMode.Stored; - case "disabled": - return SourceFieldMode.Disabled; + return SourceFieldMode.Disabled; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SourceFieldMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SourceFieldMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1128,61 +1997,130 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYes.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.Yes; + } + + if (string.Equals(value, MemberWithPositionsPayloads.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.WithPositionsPayloads; + } + + if (string.Equals(value, MemberWithPositionsOffsetsPayloads.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.WithPositionsOffsetsPayloads; + } + + if (string.Equals(value, MemberWithPositionsOffsets.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.WithPositionsOffsets; + } + + if (string.Equals(value, MemberWithPositions.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.WithPositions; + } + + if (string.Equals(value, MemberWithOffsets.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.WithOffsets; + } + + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TermVectorOption.No; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TermVectorOption ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TermVectorOption value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1201,50 +2139,101 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSummary.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeSeriesMetricType.Summary; + } + + if (string.Equals(value, MemberPosition.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeSeriesMetricType.Position; + } + + if (string.Equals(value, MemberHistogram.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeSeriesMetricType.Histogram; + } + + if (string.Equals(value, MemberGauge.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeSeriesMetricType.Gauge; + } + + if (string.Equals(value, MemberCounter.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeSeriesMetricType.Counter; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TimeSeriesMetricType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TimeSeriesMetricType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs index f2c5c6202bc..72db12ee86c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs @@ -43,51 +43,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberThreadPool.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return ClusterInfoTarget.ThreadPool; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberScript.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterInfoTarget.Script; + } + + if (string.Equals(value, MemberIngest.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterInfoTarget.Ingest; + } + + if (string.Equals(value, MemberHttp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterInfoTarget.Http; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterInfoTarget.All; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ClusterInfoTarget ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ClusterInfoTarget value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -106,51 +157,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSuccessful.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterSearchStatus.Successful; + } + + if (string.Equals(value, MemberSkipped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterSearchStatus.Skipped; + } + + if (string.Equals(value, MemberRunning.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterSearchStatus.Running; + } + + if (string.Equals(value, MemberPartial.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ClusterSearchStatus.Partial; + } + + if (string.Equals(value, MemberFailed.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return ClusterSearchStatus.Failed; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ClusterSearchStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ClusterSearchStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -173,36 +275,60 @@ 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) + if (reader.ValueTextEquals(MemberProceed)) + { + return Conflicts.Proceed; + } + + if (reader.ValueTextEquals(MemberAbort)) + { + return Conflicts.Abort; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberProceed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Conflicts.Proceed; + } + + if (string.Equals(value, MemberAbort.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "proceed": - return Conflicts.Proceed; - case "abort": - return Conflicts.Abort; + return Conflicts.Abort; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override Conflicts ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Conflicts value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -217,41 +343,74 @@ 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) + if (reader.ValueTextEquals(MemberStandardized)) + { + return DFIIndependenceMeasure.Standardized; + } + + if (reader.ValueTextEquals(MemberSaturated)) + { + return DFIIndependenceMeasure.Saturated; + } + + if (reader.ValueTextEquals(MemberChisquared)) + { + return DFIIndependenceMeasure.Chisquared; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStandardized.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFIIndependenceMeasure.Standardized; + } + + if (string.Equals(value, MemberSaturated.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFIIndependenceMeasure.Saturated; + } + + if (string.Equals(value, MemberChisquared.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override DFIIndependenceMeasure ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DFIIndependenceMeasure value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -266,41 +425,74 @@ 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) + if (reader.ValueTextEquals(MemberNo)) + { + return DFRAfterEffect.No; + } + + if (reader.ValueTextEquals(Memberl)) + { + return DFRAfterEffect.l; + } + + if (reader.ValueTextEquals(Memberb)) + { + return DFRAfterEffect.b; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "no": - return DFRAfterEffect.No; - case "l": - return DFRAfterEffect.l; - case "b": - return DFRAfterEffect.b; + return DFRAfterEffect.No; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, Memberl.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRAfterEffect.l; + } + + if (string.Equals(value, Memberb.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRAfterEffect.b; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DFRAfterEffect ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DFRAfterEffect value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -323,61 +515,130 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, Memberp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.p; + } + + if (string.Equals(value, MemberIne.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.Ine; + } + + if (string.Equals(value, MemberIn.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.In; + } + + if (string.Equals(value, MemberIf.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.If; + } + + if (string.Equals(value, Memberg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.g; + } + + if (string.Equals(value, Memberd.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DFRBasicModel.d; + } + + if (string.Equals(value, MemberBe.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return DFRBasicModel.Be; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DFRBasicModel ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DFRBasicModel value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -404,71 +665,158 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYards.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Yards; + } + + if (string.Equals(value, MemberNauticMiles.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.NauticMiles; + } + + if (string.Equals(value, MemberMillimeters.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Millimeters; + } + + if (string.Equals(value, MemberMiles.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Miles; + } + + if (string.Equals(value, MemberMeters.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Meters; + } + + if (string.Equals(value, MemberKilometers.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Kilometers; + } + + if (string.Equals(value, MemberInches.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Inches; + } + + if (string.Equals(value, MemberFeet.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return DistanceUnit.Feet; + } + + if (string.Equals(value, MemberCentimeters.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return DistanceUnit.Centimeters; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override DistanceUnit ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, DistanceUnit value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -512,51 +860,102 @@ 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) + if (reader.ValueTextEquals(MemberOpen)) { - 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; + return ExpandWildcard.Open; } - ThrowHelper.ThrowJsonException(); - return default; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberOpen.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExpandWildcard.Open; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExpandWildcard.None; + } + + if (string.Equals(value, MemberHidden.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExpandWildcard.Hidden; + } + + if (string.Equals(value, MemberClosed.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExpandWildcard.Closed; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ExpandWildcard.All; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ExpandWildcard ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ExpandWildcard value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -573,46 +972,88 @@ 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) + if (reader.ValueTextEquals(MemberLong)) + { + return FieldSortNumericType.Long; + } + + if (reader.ValueTextEquals(MemberDouble)) { - case "long": - return FieldSortNumericType.Long; - case "double": - return FieldSortNumericType.Double; - case "date_nanos": - return FieldSortNumericType.DateNanos; - case "date": - return FieldSortNumericType.Date; + return FieldSortNumericType.Double; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDateNanos)) + { + return FieldSortNumericType.DateNanos; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return FieldSortNumericType.Date; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberLong.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldSortNumericType.Long; + } + + if (string.Equals(value, MemberDouble.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldSortNumericType.Double; + } + + if (string.Equals(value, MemberDateNanos.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldSortNumericType.DateNanos; + } + + if (string.Equals(value, MemberDate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldSortNumericType.Date; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override FieldSortNumericType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FieldSortNumericType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -635,36 +1076,60 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberPlane.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoDistanceType.Plane; + } + + if (string.Equals(value, MemberArc.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoDistanceType.Arc; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override GeoDistanceType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoDistanceType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -702,46 +1167,88 @@ 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) + if (reader.ValueTextEquals(MemberWithin)) + { + return GeoShapeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) + { + return GeoShapeRelation.Intersects; + } + + if (reader.ValueTextEquals(MemberDisjoint)) + { + return GeoShapeRelation.Disjoint; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return GeoShapeRelation.Contains; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWithin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoShapeRelation.Within; + } + + if (string.Equals(value, MemberIntersects.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoShapeRelation.Intersects; + } + + if (string.Equals(value, MemberDisjoint.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "within": - return GeoShapeRelation.Within; - case "intersects": - return GeoShapeRelation.Intersects; - case "disjoint": - return GeoShapeRelation.Disjoint; - case "contains": - return GeoShapeRelation.Contains; + return GeoShapeRelation.Disjoint; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberContains.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoShapeRelation.Contains; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override GeoShapeRelation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoShapeRelation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -771,44 +1278,77 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYellow.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberYellow1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HealthStatus.Yellow; + } + + if (string.Equals(value, MemberRed.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberRed1.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "yellow": - case "YELLOW": - return HealthStatus.Yellow; - case "red": - case "RED": - return HealthStatus.Red; - case "green": - case "GREEN": - return HealthStatus.Green; + return HealthStatus.Red; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberGreen.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberGreen1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return HealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override HealthStatus ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, HealthStatus value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -821,36 +1361,60 @@ 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) + if (reader.ValueTextEquals(MemberSpl)) + { + return IBDistribution.Spl; + } + + if (reader.ValueTextEquals(MemberLl)) + { + return IBDistribution.Ll; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSpl.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "spl": - return IBDistribution.Spl; - case "ll": - return IBDistribution.Ll; + return IBDistribution.Spl; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberLl.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IBDistribution.Ll; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IBDistribution ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IBDistribution value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -863,36 +1427,60 @@ 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) + if (reader.ValueTextEquals(MemberTtf)) + { + return IBLambda.Ttf; + } + + if (reader.ValueTextEquals(MemberDf)) + { + return IBLambda.Df; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberTtf.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "ttf": - return IBLambda.Ttf; - case "df": - return IBLambda.Df; + return IBLambda.Ttf; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberDf.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IBLambda.Df; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override IBLambda ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IBLambda value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -907,41 +1495,74 @@ 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) + if (reader.ValueTextEquals(MemberShards)) + { + return Level.Shards; + } + + if (reader.ValueTextEquals(MemberIndices)) + { + return Level.Indices; + } + + if (reader.ValueTextEquals(MemberCluster)) + { + return Level.Cluster; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberShards.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Level.Shards; + } + + if (string.Equals(value, MemberIndices.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "shards": - return Level.Shards; - case "indices": - return Level.Indices; - case "cluster": - return Level.Cluster; + return Level.Indices; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberCluster.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Level.Cluster; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override Level ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Level value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -956,41 +1577,74 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LifecycleOperationMode.Stopping; + } + + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LifecycleOperationMode.Stopped; + } + + if (string.Equals(value, MemberRunning.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return LifecycleOperationMode.Running; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override LifecycleOperationMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, LifecycleOperationMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1027,96 +1681,228 @@ 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) - { - 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; - } - - public override void Write(Utf8JsonWriter writer, NodeRole value, 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) + { + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberVotingOnly.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.VotingOnly; + } + + if (string.Equals(value, MemberTransform.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Transform; + } + + if (string.Equals(value, MemberRemoteClusterClient.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.RemoteClusterClient; + } + + if (string.Equals(value, MemberMl.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Ml; + } + + if (string.Equals(value, MemberMaster.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Master; + } + + if (string.Equals(value, MemberIngest.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Ingest; + } + + if (string.Equals(value, MemberDataWarm.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.DataWarm; + } + + if (string.Equals(value, MemberDataHot.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.DataHot; + } + + if (string.Equals(value, MemberDataFrozen.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.DataFrozen; + } + + if (string.Equals(value, MemberDataContent.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.DataContent; + } + + if (string.Equals(value, MemberDataCold.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.DataCold; + } + + if (string.Equals(value, MemberData.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Data; + } + + if (string.Equals(value, MemberCoordinatingOnly.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.CoordinatingOnly; + } + + if (string.Equals(value, MemberClient.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return NodeRole.Client; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(NodeRole)}'."); + } + + 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)}'."); } + } + + public override NodeRole ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, NodeRole value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1135,51 +1921,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, Memberz.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Normalization.z; + } + + if (string.Equals(value, MemberNo.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Normalization.No; + } + + if (string.Equals(value, MemberH3.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Normalization.H3; + } + + if (string.Equals(value, MemberH2.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Normalization.H2; + } + + if (string.Equals(value, MemberH1.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return Normalization.H1; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override Normalization ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Normalization value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1198,51 +2035,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUpdated.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Result.Updated; + } + + if (string.Equals(value, MemberNotFound.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Result.NotFound; + } + + if (string.Equals(value, MemberNoOp.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Result.NoOp; + } + + if (string.Equals(value, MemberDeleted.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return Result.Deleted; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberCreated.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Result.Created; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override Result ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Result value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1250,9 +2138,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 +2197,74 @@ 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) + if (reader.ValueTextEquals(MemberVersion)) + { + return ScriptSortType.Version; + } + + if (reader.ValueTextEquals(MemberString)) + { + return ScriptSortType.String; + } + + if (reader.ValueTextEquals(MemberNumber)) + { + return ScriptSortType.Number; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberVersion.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScriptSortType.Version; + } + + if (string.Equals(value, MemberString.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ScriptSortType.String; + } + + if (string.Equals(value, MemberNumber.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override ScriptSortType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ScriptSortType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1364,36 +2287,60 @@ 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) + if (reader.ValueTextEquals(MemberQueryThenFetch)) + { + return SearchType.QueryThenFetch; + } + + if (reader.ValueTextEquals(MemberDfsQueryThenFetch)) + { + return SearchType.DfsQueryThenFetch; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberQueryThenFetch.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "query_then_fetch": - return SearchType.QueryThenFetch; - case "dfs_query_then_fetch": - return SearchType.DfsQueryThenFetch; + return SearchType.QueryThenFetch; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberDfsQueryThenFetch.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SearchType.DfsQueryThenFetch; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SearchType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SearchType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1409,31 +2356,46 @@ 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) + if (reader.ValueTextEquals(MemberAuto)) + { + return SlicesCalculation.Auto; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberAuto.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "auto": - return SlicesCalculation.Auto; + return SlicesCalculation.Auto; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SlicesCalculation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SlicesCalculation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1452,51 +2414,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SortMode.Sum; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return SortMode.Min; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberMedian.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SortMode.Median; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SortMode.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SortMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SortMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SortMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1519,36 +2532,60 @@ 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) + if (reader.ValueTextEquals(MemberDesc)) + { + return SortOrder.Desc; + } + + if (reader.ValueTextEquals(MemberAsc)) + { + return SortOrder.Asc; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberDesc.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SortOrder.Desc; + } + + if (string.Equals(value, MemberAsc.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "desc": - return SortOrder.Desc; - case "asc": - return SortOrder.Asc; + return SortOrder.Asc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override SortOrder ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SortOrder value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1578,41 +2615,74 @@ 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) + if (reader.ValueTextEquals(MemberPopular)) + { + return SuggestMode.Popular; + } + + if (reader.ValueTextEquals(MemberMissing)) + { + return SuggestMode.Missing; + } + + if (reader.ValueTextEquals(MemberAlways)) + { + return SuggestMode.Always; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPopular.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SuggestMode.Popular; + } + + if (string.Equals(value, MemberMissing.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SuggestMode.Missing; + } + + if (string.Equals(value, MemberAlways.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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)}'."); } + } + + public override SuggestMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SuggestMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1631,51 +2701,102 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWait.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ThreadType.Wait; + } + + if (string.Equals(value, MemberMem.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ThreadType.Mem; + } + + if (string.Equals(value, MemberGpu.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return ThreadType.Gpu; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberCpu.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ThreadType.Cpu; + } + + if (string.Equals(value, MemberBlock.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ThreadType.Block; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ThreadType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ThreadType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1698,61 +2819,130 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSeconds.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Seconds; + } + + if (string.Equals(value, MemberNanoseconds.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Nanoseconds; + } + + if (string.Equals(value, MemberMinutes.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Minutes; + } + + if (string.Equals(value, MemberMilliseconds.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Milliseconds; + } + + if (string.Equals(value, MemberMicroseconds.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Microseconds; + } + + if (string.Equals(value, MemberHours.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TimeUnit.Hours; + } + + if (string.Equals(value, MemberDays.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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; + return TimeUnit.Days; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override TimeUnit ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TimeUnit value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1786,46 +2976,88 @@ 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) + if (reader.ValueTextEquals(MemberInternal)) { - case "internal": - return VersionType.Internal; - case "force": - return VersionType.Force; - case "external_gte": - return VersionType.ExternalGte; - case "external": - return VersionType.External; + return VersionType.Internal; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberForce)) + { + return VersionType.Force; + } + + if (reader.ValueTextEquals(MemberExternalGte)) + { + return VersionType.ExternalGte; + } + + if (reader.ValueTextEquals(MemberExternal)) + { + return VersionType.External; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberInternal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return VersionType.Internal; + } + + if (string.Equals(value, MemberForce.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return VersionType.Force; + } + + if (string.Equals(value, MemberExternalGte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return VersionType.ExternalGte; + } + + if (string.Equals(value, MemberExternal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return VersionType.External; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override VersionType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, VersionType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1846,55 +3078,115 @@ 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) + if (reader.ValueTextEquals(MemberUrgent)) + { + return WaitForEvents.Urgent; + } + + if (reader.ValueTextEquals(MemberNormal)) + { + return WaitForEvents.Normal; + } + + if (reader.ValueTextEquals(MemberLow)) { - 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; + return WaitForEvents.Low; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLanguid)) + { + return WaitForEvents.Languid; + } + + if (reader.ValueTextEquals(MemberImmediate)) + { + return WaitForEvents.Immediate; + } + + if (reader.ValueTextEquals(MemberHigh)) + { + return WaitForEvents.High; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberUrgent.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.Urgent; + } + + if (string.Equals(value, MemberNormal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.Normal; + } + + if (string.Equals(value, MemberLow.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.Low; + } + + if (string.Equals(value, MemberLanguid.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.Languid; + } + + if (string.Equals(value, MemberImmediate.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.Immediate; + } + + if (string.Equals(value, MemberHigh.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return WaitForEvents.High; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override WaitForEvents ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, WaitForEvents value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs index 3af92fe8e4b..fb287a6a957 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs @@ -43,51 +43,102 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChildScoreMode.Sum; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChildScoreMode.None; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChildScoreMode.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChildScoreMode.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ChildScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ChildScoreMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ChildScoreMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -100,36 +151,60 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberOr.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CombinedFieldsOperator.Or; + } + + if (string.Equals(value, MemberAnd.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CombinedFieldsOperator.And; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override CombinedFieldsOperator ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsOperator value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -152,36 +227,60 @@ 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) + if (reader.ValueTextEquals(MemberNone)) + { + return CombinedFieldsZeroTerms.None; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return CombinedFieldsZeroTerms.All; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return CombinedFieldsZeroTerms.None; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "none": - return CombinedFieldsZeroTerms.None; - case "all": - return CombinedFieldsZeroTerms.All; + return CombinedFieldsZeroTerms.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override CombinedFieldsZeroTerms ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsZeroTerms value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -262,76 +361,172 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSquare.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Square; + } + + if (string.Equals(value, MemberSqrt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Sqrt; + } + + if (string.Equals(value, MemberReciprocal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Reciprocal; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.None; + } + + if (string.Equals(value, MemberLog2p.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Log2p; + } + + if (string.Equals(value, MemberLog1p.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Log1p; + } + + if (string.Equals(value, MemberLog.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Log; + } + + if (string.Equals(value, MemberLn2p.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Ln2p; + } + + if (string.Equals(value, MemberLn1p.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Ln1p; + } + + if (string.Equals(value, MemberLn.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FieldValueFactorModifier.Ln; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override FieldValueFactorModifier ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FieldValueFactorModifier value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -383,56 +578,116 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Sum; + } + + if (string.Equals(value, MemberReplace.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Replace; + } + + if (string.Equals(value, MemberMultiply.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Multiply; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionBoostMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override FunctionBoostMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FunctionBoostMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -483,56 +738,116 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.Sum; + } + + if (string.Equals(value, MemberMultiply.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.Multiply; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.Max; + } + + if (string.Equals(value, MemberFirst.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.First; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FunctionScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override FunctionScoreMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FunctionScoreMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -557,41 +872,74 @@ 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) + if (reader.ValueTextEquals(MemberStrict)) + { + return GeoValidationMethod.Strict; + } + + if (reader.ValueTextEquals(MemberIgnoreMalformed)) + { + return GeoValidationMethod.IgnoreMalformed; + } + + if (reader.ValueTextEquals(MemberCoerce)) + { + return GeoValidationMethod.Coerce; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStrict.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoValidationMethod.Strict; + } + + if (string.Equals(value, MemberIgnoreMalformed.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "strict": - return GeoValidationMethod.Strict; - case "ignore_malformed": - return GeoValidationMethod.IgnoreMalformed; - case "coerce": - return GeoValidationMethod.Coerce; + return GeoValidationMethod.IgnoreMalformed; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberCoerce.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GeoValidationMethod.Coerce; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override GeoValidationMethod ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GeoValidationMethod value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -628,46 +976,88 @@ 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) + 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)) + { + return MultiValueMode.Avg; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MultiValueMode.Sum; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MultiValueMode.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return MultiValueMode.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) { - 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 member '{value}' 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(); + public override MultiValueMode ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, MultiValueMode value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -680,38 +1070,62 @@ 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) + 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; + var value = reader.GetString()!; + if (string.Equals(value, MemberOr.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberOr1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Operator.Or; + } + + if (string.Equals(value, MemberAnd.Value, System.StringComparison.OrdinalIgnoreCase) || string.Equals(value, MemberAnd1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Operator.And; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override Operator ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Operator value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -741,41 +1155,74 @@ 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) + if (reader.ValueTextEquals(MemberWithin)) + { + return RangeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) + { + return RangeRelation.Intersects; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return RangeRelation.Contains; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberWithin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RangeRelation.Within; + } + + if (string.Equals(value, MemberIntersects.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RangeRelation.Intersects; + } + + if (string.Equals(value, MemberContains.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "within": - return RangeRelation.Within; - case "intersects": - return RangeRelation.Intersects; - case "contains": - return RangeRelation.Contains; + return RangeRelation.Contains; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override RangeRelation ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RangeRelation value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1008,56 +1455,116 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPhrasePrefix.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.PhrasePrefix; + } + + if (string.Equals(value, MemberPhrase.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.Phrase; + } + + if (string.Equals(value, MemberMostFields.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.MostFields; + } + + if (string.Equals(value, MemberCrossFields.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.CrossFields; + } + + if (string.Equals(value, MemberBoolPrefix.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.BoolPrefix; + } + + if (string.Equals(value, MemberBestFields.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TextQueryType.BestFields; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override TextQueryType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TextQueryType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -1080,35 +1587,59 @@ 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) + if (reader.ValueTextEquals(MemberNone)) + { + return ZeroTermsQuery.None; + } + + if (reader.ValueTextEquals(MemberAll)) { - case "none": - return ZeroTermsQuery.None; - case "all": - return ZeroTermsQuery.All; + return ZeroTermsQuery.All; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ZeroTermsQuery.None; + } + + if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ZeroTermsQuery.All; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ZeroTermsQuery ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ZeroTermsQuery value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs index 2a8f7fef228..75b53baba88 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs @@ -57,86 +57,200 @@ 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; + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberSuffix.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Suffix; + } + + if (string.Equals(value, MemberPrefix.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Prefix; + } + + if (string.Equals(value, MemberLte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Lte; + } + + if (string.Equals(value, MemberLt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Lt; + } + + if (string.Equals(value, MemberGte.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Gte; + } + + if (string.Equals(value, MemberGt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Gt; + } + + if (string.Equals(value, MemberGlobal.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Global; + } + + if (string.Equals(value, MemberFuzzy.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Fuzzy; + } + + if (string.Equals(value, MemberExactFuzzy.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.ExactFuzzy; + } + + if (string.Equals(value, MemberExact.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Exact; + } + + if (string.Equals(value, MemberContains.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Contains; + } + + if (string.Equals(value, MemberAlways.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleCriteriaType.Always; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override QueryRuleCriteriaType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, QueryRuleCriteriaType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -149,35 +263,59 @@ 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) + if (reader.ValueTextEquals(MemberPinned)) + { + return QueryRuleType.Pinned; + } + + if (reader.ValueTextEquals(MemberExclude)) { - case "pinned": - return QueryRuleType.Pinned; - case "exclude": - return QueryRuleType.Exclude; + return QueryRuleType.Exclude; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberPinned.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleType.Pinned; + } + + if (string.Equals(value, MemberExclude.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return QueryRuleType.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override QueryRuleType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, QueryRuleType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs index 21d54ddc082..26e947968da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs @@ -43,51 +43,102 @@ public enum IndexingJobState Aborting } -internal sealed class IndexingJobStateConverter : JsonConverter +internal sealed partial class IndexingJobStateConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexingJobState 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 MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexing = System.Text.Json.JsonEncodedText.Encode("indexing"); + private static readonly System.Text.Json.JsonEncodedText MemberAborting = System.Text.Json.JsonEncodedText.Encode("aborting"); + + public override IndexingJobState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "stopping": - return IndexingJobState.Stopping; - case "stopped": - return IndexingJobState.Stopped; - case "started": - return IndexingJobState.Started; - case "indexing": - return IndexingJobState.Indexing; - case "aborting": - return IndexingJobState.Aborting; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStopping)) + { + return IndexingJobState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return IndexingJobState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return IndexingJobState.Started; + } + + if (reader.ValueTextEquals(MemberIndexing)) + { + return IndexingJobState.Indexing; + } + + if (reader.ValueTextEquals(MemberAborting)) + { + return IndexingJobState.Aborting; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStopping.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexingJobState.Stopping; + } + + if (string.Equals(value, MemberStopped.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexingJobState.Stopped; + } + + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexingJobState.Started; + } + + if (string.Equals(value, MemberIndexing.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexingJobState.Indexing; + } + + if (string.Equals(value, MemberAborting.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return IndexingJobState.Aborting; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(IndexingJobState)}'."); } - public override void Write(Utf8JsonWriter writer, IndexingJobState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexingJobState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexingJobState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case IndexingJobState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case IndexingJobState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case IndexingJobState.Indexing: - writer.WriteStringValue("indexing"); - return; + writer.WriteStringValue(MemberIndexing); + break; case IndexingJobState.Aborting: - writer.WriteStringValue("aborting"); - return; + writer.WriteStringValue(MemberAborting); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexingJobState)}'."); } + } - writer.WriteNullValue(); + public override IndexingJobState ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, IndexingJobState value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -106,50 +157,101 @@ public enum Metric Avg } -internal sealed class MetricConverter : JsonConverter +internal sealed partial class MetricConverter : System.Text.Json.Serialization.JsonConverter { - public override Metric 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"); + 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 Metric Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "value_count": - return Metric.ValueCount; - case "sum": - return Metric.Sum; - case "min": - return Metric.Min; - case "max": - return Metric.Max; - case "avg": - return Metric.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberValueCount)) + { + return Metric.ValueCount; + } + + if (reader.ValueTextEquals(MemberSum)) + { + return Metric.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return Metric.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return Metric.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return Metric.Avg; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberValueCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Metric.ValueCount; + } + + if (string.Equals(value, MemberSum.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Metric.Sum; + } + + if (string.Equals(value, MemberMin.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Metric.Min; + } + + if (string.Equals(value, MemberMax.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Metric.Max; + } + + if (string.Equals(value, MemberAvg.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return Metric.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(Metric)}'."); } - public override void Write(Utf8JsonWriter writer, Metric value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Metric value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Metric.ValueCount: - writer.WriteStringValue("value_count"); - return; + writer.WriteStringValue(MemberValueCount); + break; case Metric.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case Metric.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case Metric.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case Metric.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Metric)}'."); } + } - writer.WriteNullValue(); + public override Metric ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Metric value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs index 347c56fa44b..4690bfdb874 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs @@ -39,40 +39,73 @@ public enum StatsLevel Cluster } -internal sealed class StatsLevelConverter : JsonConverter +internal sealed partial class StatsLevelConverter : System.Text.Json.Serialization.JsonConverter { - public override StatsLevel 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 StatsLevel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberShards)) + { + return StatsLevel.Shards; + } + + if (reader.ValueTextEquals(MemberIndices)) { - case "shards": - return StatsLevel.Shards; - case "indices": - return StatsLevel.Indices; - case "cluster": - return StatsLevel.Cluster; + return StatsLevel.Indices; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCluster)) + { + return StatsLevel.Cluster; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberShards.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StatsLevel.Shards; + } + + if (string.Equals(value, MemberIndices.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StatsLevel.Indices; + } + + if (string.Equals(value, MemberCluster.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return StatsLevel.Cluster; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(StatsLevel)}'."); } - public override void Write(Utf8JsonWriter writer, StatsLevel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StatsLevel value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case StatsLevel.Shards: - writer.WriteStringValue("shards"); - return; + writer.WriteStringValue(MemberShards); + break; case StatsLevel.Indices: - writer.WriteStringValue("indices"); - return; + writer.WriteStringValue(MemberIndices); + break; case StatsLevel.Cluster: - writer.WriteStringValue("cluster"); - return; + writer.WriteStringValue(MemberCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(StatsLevel)}'."); } + } - writer.WriteNullValue(); + public override StatsLevel ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, StatsLevel value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs index a73a00e061d..431e683b9d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs @@ -41,46 +41,88 @@ 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) + if (reader.ValueTextEquals(MemberRefreshToken)) + { + return AccessTokenGrantType.RefreshToken; + } + + if (reader.ValueTextEquals(MemberPassword)) + { + return AccessTokenGrantType.Password; + } + + if (reader.ValueTextEquals(MemberKerberos)) { - case "refresh_token": - return AccessTokenGrantType.RefreshToken; - case "password": - return AccessTokenGrantType.Password; - case "_kerberos": - return AccessTokenGrantType.Kerberos; - case "client_credentials": - return AccessTokenGrantType.ClientCredentials; + return AccessTokenGrantType.Kerberos; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberClientCredentials)) + { + return AccessTokenGrantType.ClientCredentials; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRefreshToken.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AccessTokenGrantType.RefreshToken; + } + + if (string.Equals(value, MemberPassword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AccessTokenGrantType.Password; + } + + if (string.Equals(value, MemberKerberos.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AccessTokenGrantType.Kerberos; + } + + if (string.Equals(value, MemberClientCredentials.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return AccessTokenGrantType.ClientCredentials; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override AccessTokenGrantType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, AccessTokenGrantType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -93,36 +135,60 @@ 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) + if (reader.ValueTextEquals(MemberPassword)) + { + return ApiKeyGrantType.Password; + } + + if (reader.ValueTextEquals(MemberAccessToken)) + { + return ApiKeyGrantType.AccessToken; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberPassword.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "password": - return ApiKeyGrantType.Password; - case "access_token": - return ApiKeyGrantType.AccessToken; + return ApiKeyGrantType.Password; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberAccessToken.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ApiKeyGrantType.AccessToken; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ApiKeyGrantType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ApiKeyGrantType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -135,36 +201,60 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberRest.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ApiKeyType.Rest; + } + + if (string.Equals(value, MemberCrossCluster.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ApiKeyType.CrossCluster; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ApiKeyType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ApiKeyType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -172,9 +262,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 WriteFleetSecrets { get; } = new ClusterPrivilege("write_fleet_secrets"); public static ClusterPrivilege WriteConnectorSecrets { get; } = new ClusterPrivilege("write_connector_secrets"); @@ -268,36 +360,60 @@ 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) + if (reader.ValueTextEquals(MemberPassword)) + { + return GrantType.Password; + } + + if (reader.ValueTextEquals(MemberAccessToken)) { - case "password": - return GrantType.Password; - case "access_token": - return GrantType.AccessToken; + return GrantType.AccessToken; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberPassword.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GrantType.Password; + } + + if (string.Equals(value, MemberAccessToken.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GrantType.AccessToken; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override GrantType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GrantType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -305,9 +421,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"); @@ -354,36 +472,60 @@ public enum RemoteClusterPrivilege MonitorEnrich } -internal sealed class RemoteClusterPrivilegeConverter : JsonConverter +internal sealed partial class RemoteClusterPrivilegeConverter : System.Text.Json.Serialization.JsonConverter { - public override RemoteClusterPrivilege Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMonitorStats = System.Text.Json.JsonEncodedText.Encode("monitor_stats"); + private static readonly System.Text.Json.JsonEncodedText MemberMonitorEnrich = System.Text.Json.JsonEncodedText.Encode("monitor_enrich"); + + public override RemoteClusterPrivilege Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberMonitorStats)) + { + return RemoteClusterPrivilege.MonitorStats; + } + + if (reader.ValueTextEquals(MemberMonitorEnrich)) + { + return RemoteClusterPrivilege.MonitorEnrich; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberMonitorStats.Value, System.StringComparison.OrdinalIgnoreCase)) { - case "monitor_stats": - return RemoteClusterPrivilege.MonitorStats; - case "monitor_enrich": - return RemoteClusterPrivilege.MonitorEnrich; + return RemoteClusterPrivilege.MonitorStats; } - ThrowHelper.ThrowJsonException(); - return default; + if (string.Equals(value, MemberMonitorEnrich.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return RemoteClusterPrivilege.MonitorEnrich; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(RemoteClusterPrivilege)}'."); } - public override void Write(Utf8JsonWriter writer, RemoteClusterPrivilege value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoteClusterPrivilege value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RemoteClusterPrivilege.MonitorStats: - writer.WriteStringValue("monitor_stats"); - return; + writer.WriteStringValue(MemberMonitorStats); + break; case RemoteClusterPrivilege.MonitorEnrich: - writer.WriteStringValue("monitor_enrich"); - return; + writer.WriteStringValue(MemberMonitorEnrich); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RemoteClusterPrivilege)}'."); } + } + + public override RemoteClusterPrivilege ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, RemoteClusterPrivilege value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -391,9 +533,11 @@ public override void Write(Utf8JsonWriter writer, RemoteClusterPrivilege value, 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"); @@ -419,35 +563,59 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberString.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TemplateFormat.String; + } + + if (string.Equals(value, MemberJson.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return TemplateFormat.Json; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override TemplateFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, TemplateFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs index f6ecd4edf17..a028f17cdb8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs @@ -68,51 +68,102 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStarted)) + { + return ShardsStatsStage.Started; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStarted.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardsStatsStage.Started; + } + + if (string.Equals(value, MemberInit.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardsStatsStage.Init; + } + + if (string.Equals(value, MemberFinalize.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardsStatsStage.Finalize; + } + + if (string.Equals(value, MemberFailure.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardsStatsStage.Failure; + } + + if (string.Equals(value, MemberDone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ShardsStatsStage.Done; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override ShardsStatsStage ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ShardsStatsStage value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -135,60 +186,129 @@ 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) - { - 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; - } - - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStartTime)) + { + return SnapshotSort.StartTime; + } + + if (reader.ValueTextEquals(MemberShardCount)) + { + return SnapshotSort.ShardCount; + } + + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberStartTime.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.StartTime; + } + + if (string.Equals(value, MemberShardCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.ShardCount; + } + + if (string.Equals(value, MemberRepository.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.Repository; + } + + if (string.Equals(value, MemberName.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.Name; + } + + if (string.Equals(value, MemberIndexCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.IndexCount; + } + + if (string.Equals(value, MemberFailedShardCount.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.FailedShardCount; + } + + if (string.Equals(value, MemberDuration.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SnapshotSort.Duration; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SnapshotSort ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SnapshotSort value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs index 5b2210e7a2a..4b78b6db9e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs @@ -47,60 +47,129 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberYaml.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Yaml; + } + + if (string.Equals(value, MemberTxt.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Txt; + } + + if (string.Equals(value, MemberTsv.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Tsv; + } + + if (string.Equals(value, MemberSmile.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Smile; + } + + if (string.Equals(value, MemberJson.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Json; + } + + if (string.Equals(value, MemberCsv.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Csv; + } + + if (string.Equals(value, MemberCbor.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return SqlFormat.Cbor; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override SqlFormat ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, SqlFormat value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs index 23950271dfa..58386f1869b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs @@ -54,40 +54,73 @@ public enum GroupBy Nodes } -internal sealed class GroupByConverter : JsonConverter +internal sealed partial class GroupByConverter : System.Text.Json.Serialization.JsonConverter { - public override GroupBy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberParents = System.Text.Json.JsonEncodedText.Encode("parents"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override GroupBy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberParents)) + { + return GroupBy.Parents; + } + + if (reader.ValueTextEquals(MemberNone)) { - case "parents": - return GroupBy.Parents; - case "none": - return GroupBy.None; - case "nodes": - return GroupBy.Nodes; + return GroupBy.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNodes)) + { + return GroupBy.Nodes; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberParents.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GroupBy.Parents; + } + + if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GroupBy.None; + } + + if (string.Equals(value, MemberNodes.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return GroupBy.Nodes; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(GroupBy)}'."); } - public override void Write(Utf8JsonWriter writer, GroupBy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GroupBy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GroupBy.Parents: - writer.WriteStringValue("parents"); - return; + writer.WriteStringValue(MemberParents); + break; case GroupBy.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case GroupBy.Nodes: - writer.WriteStringValue("nodes"); - return; + writer.WriteStringValue(MemberNodes); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GroupBy)}'."); } + } - writer.WriteNullValue(); + public override GroupBy ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, GroupBy value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs index 3fc28166b89..0471b677af2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs @@ -37,36 +37,60 @@ public enum EcsCompatibilityType Disabled } -internal sealed class EcsCompatibilityTypeConverter : JsonConverter +internal sealed partial class EcsCompatibilityTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override EcsCompatibilityType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberV1 = System.Text.Json.JsonEncodedText.Encode("v1"); + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + + public override EcsCompatibilityType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberV1)) + { + return EcsCompatibilityType.V1; + } + + if (reader.ValueTextEquals(MemberDisabled)) { - case "v1": - return EcsCompatibilityType.V1; - case "disabled": - return EcsCompatibilityType.Disabled; + return EcsCompatibilityType.Disabled; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberV1.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EcsCompatibilityType.V1; + } + + if (string.Equals(value, MemberDisabled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return EcsCompatibilityType.Disabled; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(EcsCompatibilityType)}'."); } - public override void Write(Utf8JsonWriter writer, EcsCompatibilityType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EcsCompatibilityType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EcsCompatibilityType.V1: - writer.WriteStringValue("v1"); - return; + writer.WriteStringValue(MemberV1); + break; case EcsCompatibilityType.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EcsCompatibilityType)}'."); } + } - writer.WriteNullValue(); + public override EcsCompatibilityType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, EcsCompatibilityType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } @@ -83,45 +107,87 @@ public enum FormatType Delimited } -internal sealed class FormatTypeConverter : JsonConverter +internal sealed partial class FormatTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FormatType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberXml = System.Text.Json.JsonEncodedText.Encode("xml"); + private static readonly System.Text.Json.JsonEncodedText MemberSemiStructuredText = System.Text.Json.JsonEncodedText.Encode("semi_structured_text"); + private static readonly System.Text.Json.JsonEncodedText MemberNdjson = System.Text.Json.JsonEncodedText.Encode("ndjson"); + private static readonly System.Text.Json.JsonEncodedText MemberDelimited = System.Text.Json.JsonEncodedText.Encode("delimited"); + + public override FormatType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + if (reader.ValueTextEquals(MemberXml)) + { + return FormatType.Xml; + } + + if (reader.ValueTextEquals(MemberSemiStructuredText)) + { + return FormatType.SemiStructuredText; + } + + if (reader.ValueTextEquals(MemberNdjson)) + { + return FormatType.Ndjson; + } + + if (reader.ValueTextEquals(MemberDelimited)) { - case "xml": - return FormatType.Xml; - case "semi_structured_text": - return FormatType.SemiStructuredText; - case "ndjson": - return FormatType.Ndjson; - case "delimited": - return FormatType.Delimited; + return FormatType.Delimited; } - ThrowHelper.ThrowJsonException(); - return default; + var value = reader.GetString()!; + if (string.Equals(value, MemberXml.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FormatType.Xml; + } + + if (string.Equals(value, MemberSemiStructuredText.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FormatType.SemiStructuredText; + } + + if (string.Equals(value, MemberNdjson.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FormatType.Ndjson; + } + + if (string.Equals(value, MemberDelimited.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return FormatType.Delimited; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(FormatType)}'."); } - public override void Write(Utf8JsonWriter writer, FormatType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FormatType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FormatType.Xml: - writer.WriteStringValue("xml"); - return; + writer.WriteStringValue(MemberXml); + break; case FormatType.SemiStructuredText: - writer.WriteStringValue("semi_structured_text"); - return; + writer.WriteStringValue(MemberSemiStructuredText); + break; case FormatType.Ndjson: - writer.WriteStringValue("ndjson"); - return; + writer.WriteStringValue(MemberNdjson); + break; case FormatType.Delimited: - writer.WriteStringValue("delimited"); - return; + writer.WriteStringValue(MemberDelimited); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FormatType)}'."); } + } - writer.WriteNullValue(); + public override FormatType ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, FormatType value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs index fdb9af07820..ab4e0a386c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs @@ -41,45 +41,87 @@ 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) + if (reader.ValueTextEquals(MemberThrottled)) + { + return ActionStatusOptions.Throttled; + } + + if (reader.ValueTextEquals(MemberSuccess)) + { + return ActionStatusOptions.Success; + } + + if (reader.ValueTextEquals(MemberSimulated)) { - case "throttled": - return ActionStatusOptions.Throttled; - case "success": - return ActionStatusOptions.Success; - case "simulated": - return ActionStatusOptions.Simulated; - case "failure": - return ActionStatusOptions.Failure; + return ActionStatusOptions.Simulated; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFailure)) + { + return ActionStatusOptions.Failure; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberThrottled.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ActionStatusOptions.Throttled; + } + + if (string.Equals(value, MemberSuccess.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ActionStatusOptions.Success; + } + + if (string.Equals(value, MemberSimulated.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ActionStatusOptions.Simulated; + } + + if (string.Equals(value, MemberFailure.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return ActionStatusOptions.Failure; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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)}'."); } + } + + public override ActionStatusOptions ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } - writer.WriteNullValue(); + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, ActionStatusOptions value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs index 36d2bdbd1e9..fd2e9ccdc43 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs @@ -39,40 +39,73 @@ 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) + 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; + } + + var value = reader.GetString()!; + if (string.Equals(value, MemberLicense.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return XPackCategory.License; + } + + if (string.Equals(value, MemberFeatures.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return XPackCategory.Features; + } + + if (string.Equals(value, MemberBuild.Value, System.StringComparison.OrdinalIgnoreCase)) + { + return XPackCategory.Build; + } + + throw new System.Text.Json.JsonException($"Unknown member '{value}' 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(); + public override XPackCategory ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return Read(ref reader, typeToConvert, options); + } + + public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, XPackCategory value, System.Text.Json.JsonSerializerOptions options) + { + Write(writer, value, options); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs index 87713b7a04f..142c381f3db 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs @@ -27,6 +27,82 @@ namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class EqlHitsConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + private static readonly System.Text.Json.JsonEncodedText PropSequences = System.Text.Json.JsonEncodedText.Encode("sequences"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override EqlHits Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>?> propEvents = default; + LocalJsonValue>?> propSequences = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryReadProperty(ref reader, options, PropEvents, static IReadOnlyCollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null))) + { + continue; + } + + if (propSequences.TryReadProperty(ref reader, options, PropSequences, static IReadOnlyCollection>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null))) + { + continue; + } + + if (propTotal.TryReadProperty(ref reader, options, PropTotal, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlHits + { + Events = propEvents.Value +, + Sequences = propSequences.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlHits value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection>? v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropSequences, value.Sequences, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection>? v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropTotal, value.Total, null, null); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlHitsConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlHits<>); + } + + 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(EqlHitsConverter<>).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(EqlHitsConverterFactory))] public sealed partial class EqlHits { /// @@ -34,7 +110,6 @@ public sealed partial class EqlHits /// Contains events matching the query. Each object represents a matching event. /// /// - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection>? Events { get; init; } /// @@ -42,7 +117,6 @@ public sealed partial class EqlHits /// Contains event sequences matching the query. Each object represents a matching sequence. This parameter is only returned for EQL queries containing a sequence. /// /// - [JsonInclude, JsonPropertyName("sequences")] public IReadOnlyCollection>? Sequences { get; init; } /// @@ -50,6 +124,5 @@ public sealed partial class EqlHits /// Metadata about the number of matching events or sequences. /// /// - [JsonInclude, JsonPropertyName("total")] public Elastic.Clients.Elasticsearch.Core.Search.TotalHits? Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs index 6ec2792b4d5..1a52fca1a85 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs @@ -27,10 +27,104 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue>?> propFields = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMissing = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>(o, null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!))) + { + continue; + } + + if (propId.TryReadProperty(ref reader, options, PropId, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TEvent (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SourceMarker))!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>? v) => w.WriteDictionaryValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null))); + writer.WriteProperty(options, PropId, value.Id, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TEvent v) => w.WriteValueEx(o, v, 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 +132,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 +139,6 @@ public sealed partial class HitsEvent /// Name of the index containing the event. /// /// - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } /// @@ -54,7 +146,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 +153,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/_Generated/Types/Eql/HitsSequence.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs index a2f67ae5619..4334e55bfab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs @@ -27,6 +27,72 @@ namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class HitsSequenceConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + private static readonly System.Text.Json.JsonEncodedText PropJoinKeys = System.Text.Json.JsonEncodedText.Encode("join_keys"); + + public override HitsSequence Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propEvents = default; + LocalJsonValue?> propJoinKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryReadProperty(ref reader, options, PropEvents, static IReadOnlyCollection> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue>(o, null)!)) + { + continue; + } + + if (propJoinKeys.TryReadProperty(ref reader, options, PropJoinKeys, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsSequence + { + Events = propEvents.Value +, + JoinKeys = propJoinKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsSequence value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection> v) => w.WriteCollectionValue>(o, v, null)); + writer.WriteProperty(options, PropJoinKeys, value.JoinKeys, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsSequenceConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsSequence<>); + } + + 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(HitsSequenceConverter<>).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(HitsSequenceConverterFactory))] public sealed partial class HitsSequence { /// @@ -34,7 +100,6 @@ public sealed partial class HitsSequence /// Contains events matching the query. Each object represents a matching event. /// /// - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection> Events { get; init; } /// @@ -42,6 +107,5 @@ public sealed partial class HitsSequence /// Shared field values used to constrain matches in the sequence. These are defined using the by keyword in the EQL query syntax. /// /// - [JsonInclude, JsonPropertyName("join_keys")] public IReadOnlyCollection? JoinKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs index 55ae6e38d10..509037163fb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs @@ -27,72 +27,99 @@ namespace Elastic.Clients.Elasticsearch; -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 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.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; + LocalJsonValue propCausedBy = default; + LocalJsonValue propReason = default; + LocalJsonValue?> propRootCause = default; + LocalJsonValue propStackTrace = default; + LocalJsonValue?> propSuppressed = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propCausedBy.TryReadProperty(ref reader, options, PropCausedBy, null)) { - 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.TryReadProperty(ref reader, options, PropReason, null)) + { + continue; + } + + if (propRootCause.TryReadProperty(ref reader, options, PropRootCause, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propStackTrace.TryReadProperty(ref reader, options, PropStackTrace, null)) + { + continue; + } + + if (propSuppressed.TryReadProperty(ref reader, options, PropSuppressed, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + 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, null, null); + writer.WriteProperty(options, PropReason, value.Reason, null, null); + writer.WriteProperty(options, PropRootCause, value.RootCause, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropStackTrace, value.StackTrace, null, null); + writer.WriteProperty(options, PropSuppressed, value.Suppressed, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/FieldSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs index 669d99a22ce..fba4048cc78 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs @@ -27,21 +27,119 @@ namespace Elastic.Clients.Elasticsearch; +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, null); + return new FieldSort { Order = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFormat = default; + LocalJsonValue propMissing = default; + LocalJsonValue propMode = default; + LocalJsonValue propNested = default; + LocalJsonValue propNumericType = default; + LocalJsonValue propOrder = default; + LocalJsonValue propUnmappedType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, null)) + { + continue; + } + + if (propMode.TryReadProperty(ref reader, options, PropMode, null)) + { + continue; + } + + if (propNested.TryReadProperty(ref reader, options, PropNested, null)) + { + continue; + } + + if (propNumericType.TryReadProperty(ref reader, options, PropNumericType, null)) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, null)) + { + continue; + } + + if (propUnmappedType.TryReadProperty(ref reader, options, PropUnmappedType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropMissing, value.Missing, null, null); + writer.WriteProperty(options, PropMode, value.Mode, null, null); + writer.WriteProperty(options, PropNested, value.Nested, null, null); + writer.WriteProperty(options, PropNumericType, value.NumericType, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, null); + writer.WriteProperty(options, PropUnmappedType, value.UnmappedType, null, null); + 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.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] public Elastic.Clients.Elasticsearch.SortMode? Mode { get; set; } - [JsonInclude, JsonPropertyName("nested")] public Elastic.Clients.Elasticsearch.NestedSortValue? Nested { get; set; } - [JsonInclude, JsonPropertyName("numeric_type")] public Elastic.Clients.Elasticsearch.FieldSortNumericType? NumericType { get; set; } - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.SortOrder? Order { get; set; } - [JsonInclude, JsonPropertyName("unmapped_type")] public Elastic.Clients.Elasticsearch.Mapping.FieldType? UnmappedType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs index f3328e0464e..996b1bef0cf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_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.FieldMemoryUsage))] public IReadOnlyDictionary? Fields { get; init; } [JsonInclude, JsonPropertyName("memory_size")] public Elastic.Clients.Elasticsearch.ByteSize? MemorySize { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Fuzziness.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Fuzziness.g.cs index 467552231b7..a2aee6133e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Fuzziness.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Fuzziness.g.cs @@ -33,13 +33,52 @@ namespace Elastic.Clients.Elasticsearch; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(FuzzinessConverter))] public sealed partial class Fuzziness : Union { - public Fuzziness(string Fuzziness) : base(Fuzziness) + public Fuzziness(string fuzziness) : base(fuzziness) { } - public Fuzziness(int Fuzziness) : base(Fuzziness) + public Fuzziness(int fuzziness) : base(fuzziness) { } + + public static implicit operator Fuzziness(string fuzziness) => new Fuzziness(fuzziness); + public static implicit operator Fuzziness(int fuzziness) => new Fuzziness(fuzziness); +} + +internal sealed partial class FuzzinessConverter : System.Text.Json.Serialization.JsonConverter +{ + public override Fuzziness Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new Fuzziness(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new Fuzziness(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(Fuzziness)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Fuzziness value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs index d3eaa418c60..d1f7dd8d573 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs @@ -27,114 +27,93 @@ namespace Elastic.Clients.Elasticsearch; -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 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); + LocalJsonValue propField = default; + LocalJsonValue> propLocation = default; + LocalJsonValue propDistanceType = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propMode = default; + LocalJsonValue propNested = default; + LocalJsonValue propOrder = default; + LocalJsonValue propUnit = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDistanceType.TryReadProperty(ref reader, options, PropDistanceType, null)) { - 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.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) { - 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.TryReadProperty(ref reader, options, PropMode, null)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propNested.TryReadProperty(ref reader, options, PropNested, null)) + { + continue; + } - if (value.Mode is not null) - { - writer.WritePropertyName("mode"); - JsonSerializer.Serialize(writer, value.Mode, options); - } + if (propOrder.TryReadProperty(ref reader, options, PropOrder, null)) + { + continue; + } - if (value.Nested is not null) - { - writer.WritePropertyName("nested"); - JsonSerializer.Serialize(writer, value.Nested, options); - } + if (propUnit.TryReadProperty(ref reader, options, PropUnit, null)) + { + 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, null, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!); } - 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, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropMode, value.Mode, null, null); + writer.WriteProperty(options, PropNested, value.Nested, null, null); + writer.WriteProperty(options, PropOrder, value.Order, null, null); + writer.WriteProperty(options, PropUnit, value.Unit, null, null); + writer.WriteProperty(options, value.Field, value.Location, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeohashPrecision.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeohashPrecision.g.cs index 63c4fc0fb88..087dcdf698d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeohashPrecision.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeohashPrecision.g.cs @@ -35,13 +35,52 @@ namespace Elastic.Clients.Elasticsearch; /// A precision that can be expressed as a geohash length between 1 and 12, or a distance measure like "1km", "10m". /// /// +[JsonConverter(typeof(GeohashPrecisionConverter))] public sealed partial class GeohashPrecision : Union { - public GeohashPrecision(double GeohashLength) : base(GeohashLength) + public GeohashPrecision(double geohashLength) : base(geohashLength) { } - public GeohashPrecision(string Distance) : base(Distance) + public GeohashPrecision(string distance) : base(distance) { } + + public static implicit operator GeohashPrecision(double geohashLength) => new GeohashPrecision(geohashLength); + public static implicit operator GeohashPrecision(string distance) => new GeohashPrecision(distance); +} + +internal sealed partial class GeohashPrecisionConverter : System.Text.Json.Serialization.JsonConverter +{ + public override GeohashPrecision Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.Number, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new GeohashPrecision(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new GeohashPrecision(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(GeohashPrecision)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeohashPrecision value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexLifecycleManagement/Phase.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexLifecycleManagement/Phase.g.cs index 86d494d0faf..58e5969637c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexLifecycleManagement/Phase.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexLifecycleManagement/Phase.g.cs @@ -27,11 +27,58 @@ namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class PhaseConverter : 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 PropMinAge = System.Text.Json.JsonEncodedText.Encode("min_age"); + + public override Phase Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propActions = default; + LocalJsonValue?> propMinAge = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryReadProperty(ref reader, options, PropActions, null)) + { + continue; + } + + if (propMinAge.TryReadProperty(ref reader, options, PropMinAge, static Union? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT1(ref r, o, "dummy"), null, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Phase + { + Actions = propActions.Value +, + MinAge = propMinAge.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Phase value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions, null, null); + writer.WriteProperty(options, PropMinAge, value.MinAge, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union? v) => w.WriteUnionValue(o, v, null, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhaseConverter))] public sealed partial class Phase { - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.IndexLifecycleManagement.Actions? Actions { get; set; } - [JsonInclude, JsonPropertyName("min_age")] public Union? MinAge { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs index b2238856538..6b29cfe7b7b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs @@ -27,6 +27,145 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAlias = default; + LocalJsonValue?> propAliases = default; + LocalJsonValue propFilter = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexRouting = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIsHidden = default; + LocalJsonValue propIsWriteIndex = default; + LocalJsonValue propMustExist = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSearchRouting = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryReadProperty(ref reader, options, PropAlias, null)) + { + continue; + } + + if (propAliases.TryReadProperty(ref reader, options, PropAliases, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexRouting.TryReadProperty(ref reader, options, PropIndexRouting, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propIsHidden.TryReadProperty(ref reader, options, PropIsHidden, null)) + { + continue; + } + + if (propIsWriteIndex.TryReadProperty(ref reader, options, PropIsWriteIndex, null)) + { + continue; + } + + if (propMustExist.TryReadProperty(ref reader, options, PropMustExist, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSearchRouting.TryReadProperty(ref reader, options, PropSearchRouting, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAliases, value.Aliases, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFilter, value.Filter, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexRouting, value.IndexRouting, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropIsHidden, value.IsHidden, null, null); + writer.WriteProperty(options, PropIsWriteIndex, value.IsWriteIndex, null, null); + writer.WriteProperty(options, PropMustExist, value.MustExist, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSearchRouting, value.SearchRouting, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AddActionConverter))] public sealed partial class AddAction { /// @@ -35,7 +174,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.IndexAlias? Alias { get; set; } /// @@ -44,8 +182,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -53,7 +189,6 @@ public sealed partial class AddAction /// Query used to limit documents the alias can access. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Filter { get; set; } /// @@ -62,7 +197,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -72,7 +206,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("index_routing")] public Elastic.Clients.Elasticsearch.Routing? IndexRouting { get; set; } /// @@ -81,7 +214,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -89,7 +221,6 @@ public sealed partial class AddAction /// If true, the alias is hidden. /// /// - [JsonInclude, JsonPropertyName("is_hidden")] public bool? IsHidden { get; set; } /// @@ -97,7 +228,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 +235,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 +243,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -124,7 +252,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("search_routing")] public Elastic.Clients.Elasticsearch.Routing? SearchRouting { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction(AddAction addAction) => Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction.Add(addAction); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs index 266cfa6e3c0..0697e06d6fc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs @@ -27,93 +27,129 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propBytes = default; + LocalJsonValue propEndOffset = default; + LocalJsonValue propKeyword = default; + LocalJsonValue propPosition = default; + LocalJsonValue propPositionlength = default; + LocalJsonValue propStartOffset = default; + LocalJsonValue propTermfrequency = default; + LocalJsonValue propToken = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBytes.TryReadProperty(ref reader, options, PropBytes, null)) { - 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.TryReadProperty(ref reader, options, PropEndOffset, null)) + { + continue; + } + + if (propKeyword.TryReadProperty(ref reader, options, PropKeyword, null)) + { + continue; + } + + if (propPosition.TryReadProperty(ref reader, options, PropPosition, null)) + { + continue; + } + + if (propPositionlength.TryReadProperty(ref reader, options, PropPositionlength, null)) + { + continue; + } + + if (propStartOffset.TryReadProperty(ref reader, options, PropStartOffset, null)) + { + continue; + } + + if (propTermfrequency.TryReadProperty(ref reader, options, PropTermfrequency, null)) + { + continue; + } + + if (propToken.TryReadProperty(ref reader, options, PropToken, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + 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, null, null); + writer.WriteProperty(options, PropEndOffset, value.EndOffset, null, null); + writer.WriteProperty(options, PropKeyword, value.Keyword, null, null); + writer.WriteProperty(options, PropPosition, value.Position, null, null); + writer.WriteProperty(options, PropPositionlength, value.Positionlength, null, null); + writer.WriteProperty(options, PropStartOffset, value.StartOffset, null, null); + writer.WriteProperty(options, PropTermfrequency, value.Termfrequency, null, null); + writer.WriteProperty(options, PropToken, value.Token, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs index e8b87c850cc..d9705864b4d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs @@ -39,12 +39,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.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("add_backing_index", indexAndDataStreamAction); public static IndexModifyDataStreamAction RemoveBackingIndex(Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("remove_backing_index", indexAndDataStreamAction); @@ -62,67 +66,61 @@ 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."); + variantType = VariantAddBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add_backing_index") + if (reader.ValueTextEquals(VariantRemoveBackingIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "remove_backing_index") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - case "remove_backing_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - } + case "": + break; + case "add_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction?)value.Variant, null, null); + break; + case "remove_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction?)value.Variant, null, null); + 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/_Generated/Types/IndexManagement/IndexSegment.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegment.g.cs index 179034d33c5..c871675ffb3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegment.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegment.g.cs @@ -27,8 +27,46 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class IndexSegmentConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("shards"); + + public override IndexSegment Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>>> propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryReadProperty(ref reader, options, PropShards, static IReadOnlyDictionary>> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexSegment + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexSegment value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>> v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexSegmentConverter))] public sealed partial class IndexSegment { - [JsonInclude, JsonPropertyName("shards")] public IReadOnlyDictionary>> Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs index 41e475ffda0..590cb92d50d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs @@ -27,19 +27,80 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propField = default; + LocalJsonValue?> propMissing = default; + LocalJsonValue?> propMode = default; + LocalJsonValue?> propOrder = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryReadProperty(ref reader, options, PropField, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propMissing.TryReadProperty(ref reader, options, PropMissing, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMode.TryReadProperty(ref reader, options, PropMode, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propOrder.TryReadProperty(ref reader, options, PropOrder, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropMissing, value.Missing, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMode, value.Mode, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropOrder, value.Order, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexSegmentSortConverter))] public sealed partial class IndexSegmentSort { - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Field { get; set; } - [JsonInclude, JsonPropertyName("missing")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMissing))] public ICollection? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMode))] public ICollection? Mode { get; set; } - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortOrder))] public ICollection? Order { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs index 85cb6c2f4ac..85d30313101 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs @@ -27,711 +27,596 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyze = default; + LocalJsonValue propAutoExpandReplicas = default; + LocalJsonValue propBlocks = default; + LocalJsonValue propCheckOnStartup = default; + LocalJsonValue propCodec = default; + LocalJsonValue propCreationDate = default; + LocalJsonValue propCreationDateString = default; + LocalJsonValue propDefaultPipeline = default; + LocalJsonValue propFinalPipeline = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGcDeletes = default; + LocalJsonValue propHidden = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexingPressure = default; + LocalJsonValue propIndexingSlowlog = default; + LocalJsonValue propLifecycle = default; + LocalJsonValue propLoadFixedBitsetFiltersEagerly = default; + LocalJsonValue propMapping = default; + LocalJsonValue propMaxDocvalueFieldsSearch = default; + LocalJsonValue propMaxInnerResultWindow = default; + LocalJsonValue propMaxNgramDiff = default; + LocalJsonValue propMaxRefreshListeners = default; + LocalJsonValue propMaxRegexLength = default; + LocalJsonValue propMaxRescoreWindow = default; + LocalJsonValue propMaxResultWindow = default; + LocalJsonValue propMaxScriptFields = default; + LocalJsonValue propMaxShingleDiff = default; + LocalJsonValue propMaxSlicesPerScroll = default; + LocalJsonValue propMaxTermsCount = default; + LocalJsonValue propMerge = default; + LocalJsonValue propMode = default; + LocalJsonValue propNumberOfReplicas = default; + LocalJsonValue propNumberOfRoutingShards = default; + LocalJsonValue propNumberOfShards = default; + LocalJsonValue propPriority = default; + LocalJsonValue propProvidedName = default; + LocalJsonValue propQueries = default; + LocalJsonValue propQueryString = default; + LocalJsonValue propRefreshInterval = default; + LocalJsonValue propRouting = default; + LocalJsonValue propRoutingPartitionSize = default; + LocalJsonValue?> propRoutingPath = default; + LocalJsonValue propSearch = default; + LocalJsonValue propSettings = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propSoftDeletes = default; + LocalJsonValue propSort = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeries = default; + LocalJsonValue propTopMetricsMaxSize = default; + LocalJsonValue propTranslog = default; + LocalJsonValue propUuid = default; + LocalJsonValue propVerifiedBeforeClose = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalysis.TryReadProperty(ref reader, options, PropAnalysis, null)) { - 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.TryReadProperty(ref reader, options, PropAnalyze, null)) { - 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.TryReadProperty(ref reader, options, PropAutoExpandReplicas, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.AutoExpandReplicas)) - { - writer.WritePropertyName("auto_expand_replicas"); - writer.WriteStringValue(value.AutoExpandReplicas); - } + if (propBlocks.TryReadProperty(ref reader, options, PropBlocks, null)) + { + continue; + } - if (value.Blocks is not null) - { - writer.WritePropertyName("blocks"); - JsonSerializer.Serialize(writer, value.Blocks, options); - } + if (propCheckOnStartup.TryReadProperty(ref reader, options, PropCheckOnStartup, null)) + { + continue; + } - if (value.CheckOnStartup is not null) - { - writer.WritePropertyName("check_on_startup"); - JsonSerializer.Serialize(writer, value.CheckOnStartup, options); - } + if (propCodec.TryReadProperty(ref reader, options, PropCodec, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Codec)) - { - writer.WritePropertyName("codec"); - writer.WriteStringValue(value.Codec); - } + if (propCreationDate.TryReadProperty(ref reader, options, PropCreationDate, null)) + { + continue; + } - if (value.CreationDate.HasValue) - { - writer.WritePropertyName("creation_date"); - writer.WriteNumberValue(value.CreationDate.Value); - } + if (propCreationDateString.TryReadProperty(ref reader, options, PropCreationDateString, null)) + { + continue; + } - if (value.CreationDateString is not null) - { - writer.WritePropertyName("creation_date_string"); - JsonSerializer.Serialize(writer, value.CreationDateString, options); - } + if (propDefaultPipeline.TryReadProperty(ref reader, options, PropDefaultPipeline, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.DefaultPipeline)) - { - writer.WritePropertyName("default_pipeline"); - writer.WriteStringValue(value.DefaultPipeline); - } + if (propFinalPipeline.TryReadProperty(ref reader, options, PropFinalPipeline, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FinalPipeline)) - { - writer.WritePropertyName("final_pipeline"); - writer.WriteStringValue(value.FinalPipeline); - } + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } - if (value.Format is not null) - { - writer.WritePropertyName("format"); - JsonSerializer.Serialize(writer, value.Format, options); - } + if (propGcDeletes.TryReadProperty(ref reader, options, PropGcDeletes, null)) + { + continue; + } - if (value.GcDeletes is not null) - { - writer.WritePropertyName("gc_deletes"); - JsonSerializer.Serialize(writer, value.GcDeletes, options); - } + if (propHidden.TryReadProperty(ref reader, options, PropHidden, null)) + { + continue; + } - if (value.Hidden is not null) - { - writer.WritePropertyName("hidden"); - JsonSerializer.Serialize(writer, value.Hidden, options); - } + if (propHighlight.TryReadProperty(ref reader, options, PropHighlight, null)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } - if (value.Index is not null) - { - writer.WritePropertyName("index"); - JsonSerializer.Serialize(writer, value.Index, options); - } + if (propIndexingPressure.TryReadProperty(ref reader, options, PropIndexingPressure, null)) + { + continue; + } - if (value.IndexingPressure is not null) - { - writer.WritePropertyName("indexing_pressure"); - JsonSerializer.Serialize(writer, value.IndexingPressure, options); - } + if (propIndexingSlowlog.TryReadProperty(ref reader, options, PropIndexingSlowlog, null)) + { + continue; + } - if (value.IndexingSlowlog is not null) - { - writer.WritePropertyName("indexing.slowlog"); - JsonSerializer.Serialize(writer, value.IndexingSlowlog, options); - } + if (propLifecycle.TryReadProperty(ref reader, options, PropLifecycle, null)) + { + continue; + } - if (value.Lifecycle is not null) - { - writer.WritePropertyName("lifecycle"); - JsonSerializer.Serialize(writer, value.Lifecycle, options); - } + if (propLoadFixedBitsetFiltersEagerly.TryReadProperty(ref reader, options, PropLoadFixedBitsetFiltersEagerly, null)) + { + continue; + } - if (value.LoadFixedBitsetFiltersEagerly.HasValue) - { - writer.WritePropertyName("load_fixed_bitset_filters_eagerly"); - writer.WriteBooleanValue(value.LoadFixedBitsetFiltersEagerly.Value); - } + if (propMapping.TryReadProperty(ref reader, options, PropMapping, null)) + { + continue; + } - if (value.Mapping is not null) - { - writer.WritePropertyName("mapping"); - JsonSerializer.Serialize(writer, value.Mapping, options); - } + if (propMaxDocvalueFieldsSearch.TryReadProperty(ref reader, options, PropMaxDocvalueFieldsSearch, null)) + { + continue; + } - if (value.MaxDocvalueFieldsSearch.HasValue) - { - writer.WritePropertyName("max_docvalue_fields_search"); - writer.WriteNumberValue(value.MaxDocvalueFieldsSearch.Value); - } + if (propMaxInnerResultWindow.TryReadProperty(ref reader, options, PropMaxInnerResultWindow, null)) + { + continue; + } - if (value.MaxInnerResultWindow.HasValue) - { - writer.WritePropertyName("max_inner_result_window"); - writer.WriteNumberValue(value.MaxInnerResultWindow.Value); - } + if (propMaxNgramDiff.TryReadProperty(ref reader, options, PropMaxNgramDiff, null)) + { + continue; + } - if (value.MaxNgramDiff.HasValue) - { - writer.WritePropertyName("max_ngram_diff"); - writer.WriteNumberValue(value.MaxNgramDiff.Value); - } + if (propMaxRefreshListeners.TryReadProperty(ref reader, options, PropMaxRefreshListeners, null)) + { + continue; + } - if (value.MaxRefreshListeners.HasValue) - { - writer.WritePropertyName("max_refresh_listeners"); - writer.WriteNumberValue(value.MaxRefreshListeners.Value); - } + if (propMaxRegexLength.TryReadProperty(ref reader, options, PropMaxRegexLength, null)) + { + continue; + } - if (value.MaxRegexLength.HasValue) - { - writer.WritePropertyName("max_regex_length"); - writer.WriteNumberValue(value.MaxRegexLength.Value); - } + if (propMaxRescoreWindow.TryReadProperty(ref reader, options, PropMaxRescoreWindow, null)) + { + continue; + } - if (value.MaxRescoreWindow.HasValue) - { - writer.WritePropertyName("max_rescore_window"); - writer.WriteNumberValue(value.MaxRescoreWindow.Value); - } + if (propMaxResultWindow.TryReadProperty(ref reader, options, PropMaxResultWindow, null)) + { + continue; + } - if (value.MaxResultWindow.HasValue) - { - writer.WritePropertyName("max_result_window"); - writer.WriteNumberValue(value.MaxResultWindow.Value); - } + if (propMaxScriptFields.TryReadProperty(ref reader, options, PropMaxScriptFields, null)) + { + continue; + } - if (value.MaxScriptFields.HasValue) - { - writer.WritePropertyName("max_script_fields"); - writer.WriteNumberValue(value.MaxScriptFields.Value); - } + if (propMaxShingleDiff.TryReadProperty(ref reader, options, PropMaxShingleDiff, null)) + { + continue; + } - if (value.MaxShingleDiff.HasValue) - { - writer.WritePropertyName("max_shingle_diff"); - writer.WriteNumberValue(value.MaxShingleDiff.Value); - } + if (propMaxSlicesPerScroll.TryReadProperty(ref reader, options, PropMaxSlicesPerScroll, null)) + { + continue; + } - if (value.MaxSlicesPerScroll.HasValue) - { - writer.WritePropertyName("max_slices_per_scroll"); - writer.WriteNumberValue(value.MaxSlicesPerScroll.Value); - } + if (propMaxTermsCount.TryReadProperty(ref reader, options, PropMaxTermsCount, null)) + { + continue; + } - if (value.MaxTermsCount.HasValue) - { - writer.WritePropertyName("max_terms_count"); - writer.WriteNumberValue(value.MaxTermsCount.Value); - } + if (propMerge.TryReadProperty(ref reader, options, PropMerge, null)) + { + continue; + } - if (value.Merge is not null) - { - writer.WritePropertyName("merge"); - JsonSerializer.Serialize(writer, value.Merge, options); - } + if (propMode.TryReadProperty(ref reader, options, PropMode, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Mode)) - { - writer.WritePropertyName("mode"); - writer.WriteStringValue(value.Mode); - } + if (propNumberOfReplicas.TryReadProperty(ref reader, options, PropNumberOfReplicas, null)) + { + continue; + } - if (value.NumberOfReplicas is not null) - { - writer.WritePropertyName("number_of_replicas"); - JsonSerializer.Serialize(writer, value.NumberOfReplicas, options); - } + if (propNumberOfRoutingShards.TryReadProperty(ref reader, options, PropNumberOfRoutingShards, null)) + { + continue; + } - if (value.NumberOfRoutingShards.HasValue) - { - writer.WritePropertyName("number_of_routing_shards"); - writer.WriteNumberValue(value.NumberOfRoutingShards.Value); - } + if (propNumberOfShards.TryReadProperty(ref reader, options, PropNumberOfShards, null)) + { + continue; + } - if (value.NumberOfShards is not null) - { - writer.WritePropertyName("number_of_shards"); - JsonSerializer.Serialize(writer, value.NumberOfShards, options); - } + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } - if (value.Priority is not null) - { - writer.WritePropertyName("priority"); - JsonSerializer.Serialize(writer, value.Priority, options); - } + if (propProvidedName.TryReadProperty(ref reader, options, PropProvidedName, null)) + { + continue; + } - if (value.ProvidedName is not null) - { - writer.WritePropertyName("provided_name"); - JsonSerializer.Serialize(writer, value.ProvidedName, options); - } + if (propQueries.TryReadProperty(ref reader, options, PropQueries, null)) + { + continue; + } - if (value.Queries is not null) - { - writer.WritePropertyName("queries"); - JsonSerializer.Serialize(writer, value.Queries, options); - } + if (propQueryString.TryReadProperty(ref reader, options, PropQueryString, null)) + { + continue; + } - if (value.QueryString is not null) - { - writer.WritePropertyName("query_string"); - JsonSerializer.Serialize(writer, value.QueryString, options); - } + if (propRefreshInterval.TryReadProperty(ref reader, options, PropRefreshInterval, null)) + { + continue; + } - if (value.RefreshInterval is not null) - { - writer.WritePropertyName("refresh_interval"); - JsonSerializer.Serialize(writer, value.RefreshInterval, options); - } + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } - if (value.Routing is not null) - { - writer.WritePropertyName("routing"); - JsonSerializer.Serialize(writer, value.Routing, options); - } + if (propRoutingPartitionSize.TryReadProperty(ref reader, options, PropRoutingPartitionSize, null)) + { + continue; + } - if (value.RoutingPartitionSize.HasValue) - { - writer.WritePropertyName("routing_partition_size"); - writer.WriteNumberValue(value.RoutingPartitionSize.Value); - } + if (propRoutingPath.TryReadProperty(ref reader, options, PropRoutingPath, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } - if (value.RoutingPath is not null) - { - writer.WritePropertyName("routing_path"); - JsonSerializer.Serialize(writer, value.RoutingPath, options); - } + if (propSearch.TryReadProperty(ref reader, options, PropSearch, null)) + { + continue; + } - if (value.Search is not null) - { - writer.WritePropertyName("search"); - JsonSerializer.Serialize(writer, value.Search, options); - } + if (propSettings.TryReadProperty(ref reader, options, PropSettings, null)) + { + continue; + } - if (value.Settings is not null) - { - writer.WritePropertyName("settings"); - JsonSerializer.Serialize(writer, value.Settings, options); - } + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } - if (value.Similarity is not null) - { - writer.WritePropertyName("similarity"); - JsonSerializer.Serialize(writer, value.Similarity, options); - } + if (propSoftDeletes.TryReadProperty(ref reader, options, PropSoftDeletes, null)) + { + continue; + } - if (value.SoftDeletes is not null) - { - writer.WritePropertyName("soft_deletes"); - JsonSerializer.Serialize(writer, value.SoftDeletes, options); - } + if (propSort.TryReadProperty(ref reader, options, PropSort, null)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } - if (value.Store is not null) - { - writer.WritePropertyName("store"); - JsonSerializer.Serialize(writer, value.Store, options); - } + if (propTimeSeries.TryReadProperty(ref reader, options, PropTimeSeries, null)) + { + continue; + } - if (value.TimeSeries is not null) - { - writer.WritePropertyName("time_series"); - JsonSerializer.Serialize(writer, value.TimeSeries, options); - } + if (propTopMetricsMaxSize.TryReadProperty(ref reader, options, PropTopMetricsMaxSize, null)) + { + continue; + } - if (value.TopMetricsMaxSize.HasValue) - { - writer.WritePropertyName("top_metrics_max_size"); - writer.WriteNumberValue(value.TopMetricsMaxSize.Value); - } + if (propTranslog.TryReadProperty(ref reader, options, PropTranslog, null)) + { + continue; + } - if (value.Translog is not null) - { - writer.WritePropertyName("translog"); - JsonSerializer.Serialize(writer, value.Translog, options); - } + if (propUuid.TryReadProperty(ref reader, options, PropUuid, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Uuid)) - { - writer.WritePropertyName("uuid"); - writer.WriteStringValue(value.Uuid); - } + if (propVerifiedBeforeClose.TryReadProperty(ref reader, options, PropVerifiedBeforeClose, null)) + { + continue; + } - if (value.VerifiedBeforeClose is not null) - { - writer.WritePropertyName("verified_before_close"); - JsonSerializer.Serialize(writer, value.VerifiedBeforeClose, options); - } + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + 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, null, null); + writer.WriteProperty(options, PropAnalyze, value.Analyze, null, null); + writer.WriteProperty(options, PropAutoExpandReplicas, value.AutoExpandReplicas, null, null); + writer.WriteProperty(options, PropBlocks, value.Blocks, null, null); + writer.WriteProperty(options, PropCheckOnStartup, value.CheckOnStartup, null, null); + writer.WriteProperty(options, PropCodec, value.Codec, null, null); + writer.WriteProperty(options, PropCreationDate, value.CreationDate, null, null); + writer.WriteProperty(options, PropCreationDateString, value.CreationDateString, null, null); + writer.WriteProperty(options, PropDefaultPipeline, value.DefaultPipeline, null, null); + writer.WriteProperty(options, PropFinalPipeline, value.FinalPipeline, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropGcDeletes, value.GcDeletes, null, null); + writer.WriteProperty(options, PropHidden, value.Hidden, null, null); + writer.WriteProperty(options, PropHighlight, value.Highlight, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure, null, null); + writer.WriteProperty(options, PropIndexingSlowlog, value.IndexingSlowlog, null, null); + writer.WriteProperty(options, PropLifecycle, value.Lifecycle, null, null); + writer.WriteProperty(options, PropLoadFixedBitsetFiltersEagerly, value.LoadFixedBitsetFiltersEagerly, null, null); + writer.WriteProperty(options, PropMapping, value.Mapping, null, null); + writer.WriteProperty(options, PropMaxDocvalueFieldsSearch, value.MaxDocvalueFieldsSearch, null, null); + writer.WriteProperty(options, PropMaxInnerResultWindow, value.MaxInnerResultWindow, null, null); + writer.WriteProperty(options, PropMaxNgramDiff, value.MaxNgramDiff, null, null); + writer.WriteProperty(options, PropMaxRefreshListeners, value.MaxRefreshListeners, null, null); + writer.WriteProperty(options, PropMaxRegexLength, value.MaxRegexLength, null, null); + writer.WriteProperty(options, PropMaxRescoreWindow, value.MaxRescoreWindow, null, null); + writer.WriteProperty(options, PropMaxResultWindow, value.MaxResultWindow, null, null); + writer.WriteProperty(options, PropMaxScriptFields, value.MaxScriptFields, null, null); + writer.WriteProperty(options, PropMaxShingleDiff, value.MaxShingleDiff, null, null); + writer.WriteProperty(options, PropMaxSlicesPerScroll, value.MaxSlicesPerScroll, null, null); + writer.WriteProperty(options, PropMaxTermsCount, value.MaxTermsCount, null, null); + writer.WriteProperty(options, PropMerge, value.Merge, null, null); + writer.WriteProperty(options, PropMode, value.Mode, null, null); + writer.WriteProperty(options, PropNumberOfReplicas, value.NumberOfReplicas, null, null); + writer.WriteProperty(options, PropNumberOfRoutingShards, value.NumberOfRoutingShards, null, null); + writer.WriteProperty(options, PropNumberOfShards, value.NumberOfShards, null, null); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropProvidedName, value.ProvidedName, null, null); + writer.WriteProperty(options, PropQueries, value.Queries, null, null); + writer.WriteProperty(options, PropQueryString, value.QueryString, null, null); + writer.WriteProperty(options, PropRefreshInterval, value.RefreshInterval, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropRoutingPartitionSize, value.RoutingPartitionSize, null, null); + writer.WriteProperty(options, PropRoutingPath, value.RoutingPath, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSearch, value.Search, null, null); + writer.WriteProperty(options, PropSettings, value.Settings, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteProperty(options, PropSoftDeletes, value.SoftDeletes, null, null); + writer.WriteProperty(options, PropSort, value.Sort, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeries, value.TimeSeries, null, null); + writer.WriteProperty(options, PropTopMetricsMaxSize, value.TopMetricsMaxSize, null, null); + writer.WriteProperty(options, PropTranslog, value.Translog, null, null); + writer.WriteProperty(options, PropUuid, value.Uuid, null, null); + writer.WriteProperty(options, PropVerifiedBeforeClose, value.VerifiedBeforeClose, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + 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/_Generated/Types/IndexManagement/IndexTemplate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs index f66dc302ac4..74c26a53eca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs @@ -27,9 +27,137 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowAutoCreate = default; + LocalJsonValue> propComposedOf = default; + LocalJsonValue propDataStream = default; + LocalJsonValue propDeprecated = default; + LocalJsonValue?> propIgnoreMissingComponentTemplates = default; + LocalJsonValue> propIndexPatterns = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPriority = default; + LocalJsonValue propTemplate = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowAutoCreate.TryReadProperty(ref reader, options, PropAllowAutoCreate, null)) + { + continue; + } + + if (propComposedOf.TryReadProperty(ref reader, options, PropComposedOf, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propDataStream.TryReadProperty(ref reader, options, PropDataStream, null)) + { + continue; + } + + if (propDeprecated.TryReadProperty(ref reader, options, PropDeprecated, null)) + { + continue; + } + + if (propIgnoreMissingComponentTemplates.TryReadProperty(ref reader, options, PropIgnoreMissingComponentTemplates, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propIndexPatterns.TryReadProperty(ref reader, options, PropIndexPatterns, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } + + if (propTemplate.TryReadProperty(ref reader, options, PropTemplate, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropComposedOf, value.ComposedOf, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropDataStream, value.DataStream, null, null); + writer.WriteProperty(options, PropDeprecated, value.Deprecated, null, null); + writer.WriteProperty(options, PropIgnoreMissingComponentTemplates, value.IgnoreMissingComponentTemplates, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndexPatterns, value.IndexPatterns, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropTemplate, value.Template, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexTemplateConverter))] public sealed partial class IndexTemplate { - [JsonInclude, JsonPropertyName("allow_auto_create")] public bool? AllowAutoCreate { get; init; } /// @@ -38,7 +166,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 +175,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.IndexManagement.IndexTemplateDataStreamConfiguration? DataStream { get; init; } /// @@ -58,7 +184,6 @@ public sealed partial class IndexTemplate /// Elasticsearch will emit a deprecation warning. /// /// - [JsonInclude, JsonPropertyName("deprecated")] public bool? Deprecated { get; init; } /// @@ -66,8 +191,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 +198,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 +206,6 @@ public sealed partial class IndexTemplate /// This map is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } /// @@ -96,7 +216,6 @@ public sealed partial class IndexTemplate /// This number is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("priority")] public long? Priority { get; init; } /// @@ -105,7 +224,6 @@ public sealed partial class IndexTemplate /// It may optionally include an aliases, mappings, or settings configuration. /// /// - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexTemplateSummary? Template { get; init; } /// @@ -114,6 +232,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/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs index be455d697cb..16857c36703 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs @@ -38,7 +38,6 @@ public sealed partial class IndexTemplateSummary /// /// [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary? Aliases { get; init; } [JsonInclude, JsonPropertyName("lifecycle")] public Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycleWithRollover? Lifecycle { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs index df29e80b76f..46b29528001 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs @@ -39,12 +39,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.IndexManagement.AddAction addAction) => new IndexUpdateAliasesAction("add", addAction); public static IndexUpdateAliasesAction Remove(Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction removeAction) => new IndexUpdateAliasesAction("remove", removeAction); @@ -63,77 +67,73 @@ 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."); + variantType = VariantAdd.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRemoveIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveIndex.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "remove_index") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.IndexManagement.AddAction)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction)value.Variant, options); - break; - case "remove_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveIndexAction)value.Variant, options); - break; - } + case "": + break; + case "add": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.AddAction?)value.Variant, null, null); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction?)value.Variant, null, null); + break; + case "remove_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveIndexAction?)value.Variant, null, null); + 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/_Generated/Types/IndexManagement/RemoveAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs index fc2de9dd136..1d56329f6a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs @@ -27,6 +27,85 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAlias = default; + LocalJsonValue?> propAliases = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndices = default; + LocalJsonValue propMustExist = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryReadProperty(ref reader, options, PropAlias, null)) + { + continue; + } + + if (propAliases.TryReadProperty(ref reader, options, PropAliases, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propMustExist.TryReadProperty(ref reader, options, PropMustExist, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAliases, value.Aliases, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropMustExist, value.MustExist, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveActionConverter))] public sealed partial class RemoveAction { /// @@ -35,7 +114,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.IndexAlias? Alias { get; set; } /// @@ -44,8 +122,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -54,7 +130,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -63,7 +138,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -71,7 +145,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.IndexManagement.IndexUpdateAliasesAction(RemoveAction removeAction) => Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction.Remove(removeAction); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs index fee1e4ee883..d5b47603397 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs @@ -27,11 +27,57 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propIndices = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropName, value.Name, null, null); + 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/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs index bde3f17ffea..4e3fed53368 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs @@ -27,13 +27,68 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue> propBackingIndices = default; + LocalJsonValue propName = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryReadProperty(ref reader, options, PropBackingIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propTimestampField.TryReadProperty(ref reader, options, PropTimestampField, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropTimestampField, value.TimestampField, null, null); + 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/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs index 49db5a56af3..07a96c42291 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs @@ -92,80 +92,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, null)) + { + 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, null), + "boolean" => reader.ReadValue(options, null), + "DFI" => reader.ReadValue(options, null), + "DFR" => reader.ReadValue(options, null), + "IB" => reader.ReadValue(options, null), + "LMDirichlet" => reader.ReadValue(options, null), + "LMJelinekMercer" => reader.ReadValue(options, null), + "scripted" => reader.ReadValue(options, null), + _ => 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.IndexManagement.SettingsSimilarityBm25), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBm25)value, null); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBoolean), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBoolean)value, null); + break; case "DFI": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfi), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfi)value, null); + break; case "DFR": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfr), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfr)value, null); + break; case "IB": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityIb), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityIb)value, null); + break; case "LMDirichlet": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmd), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmd)value, null); + break; case "LMJelinekMercer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmj), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmj)value, null); + break; case "scripted": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityScripted), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityScripted)value, null); + 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/_Generated/Types/IndexManagement/ShardStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs index 76c31252cf3..445425e2872 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs @@ -72,7 +72,6 @@ public sealed partial class ShardStats [JsonInclude, JsonPropertyName("shard_path")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardPath? ShardPath { get; init; } [JsonInclude, JsonPropertyName("shards")] - [ReadOnlyIndexNameDictionaryConverter(typeof(object))] public IReadOnlyDictionary? Shards { get; init; } [JsonInclude, JsonPropertyName("shard_stats")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardsTotalStats? ShardStats2 { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs index 45555b85e60..58f21b55852 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs @@ -27,52 +27,64 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; -internal sealed partial class ShardStoreConverter : JsonConverter +internal sealed partial class ShardStoreConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAllocation = System.Text.Json.JsonEncodedText.Encode("allocation"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationId = System.Text.Json.JsonEncodedText.Encode("allocation_id"); + private static readonly System.Text.Json.JsonEncodedText PropStoreException = System.Text.Json.JsonEncodedText.Encode("store_exception"); + + public override ShardStore 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.IndexManagement.ShardStoreAllocation allocation = default; - string? allocationId = default; - Elastic.Clients.Elasticsearch.IndexManagement.ShardStoreException? storeException = default; - string nodeId = default; - Elastic.Clients.Elasticsearch.IndexManagement.ShardStoreNode node = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNode = default; + LocalJsonValue propNodeId = default; + LocalJsonValue propAllocation = default; + LocalJsonValue propAllocationId = default; + LocalJsonValue propStoreException = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAllocation.TryReadProperty(ref reader, options, PropAllocation, null)) { - var property = reader.GetString(); - if (property == "allocation") - { - allocation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "allocation_id") - { - allocationId = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "store_exception") - { - storeException = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propAllocationId.TryReadProperty(ref reader, options, PropAllocationId, null)) + { + continue; + } - nodeId = property; - reader.Read(); - node = JsonSerializer.Deserialize(ref reader, options); + if (propStoreException.TryReadProperty(ref reader, options, PropStoreException, null)) + { + continue; } + + propNodeId.Initialized = propNode.Initialized = true; + reader.ReadProperty(options, out propNodeId.Value, out propNode.Value, null, null); } - return new ShardStore { Allocation = allocation, AllocationId = allocationId, Node = node, NodeId = nodeId, StoreException = storeException }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShardStore + { + Node = propNode.Value +, + NodeId = propNodeId.Value +, + Allocation = propAllocation.Value +, + AllocationId = propAllocationId.Value +, + StoreException = propStoreException.Value + }; } - public override void Write(Utf8JsonWriter writer, ShardStore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStore value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ShardStore' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllocation, value.Allocation, null, null); + writer.WriteProperty(options, PropAllocationId, value.AllocationId, null, null); + writer.WriteProperty(options, PropStoreException, value.StoreException, null, null); + writer.WriteProperty(options, value.NodeId, value.Node, null, null); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs index fbbf7a1f103..98603afb8a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class Template { [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary Aliases { get; init; } [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs index a64d9721337..c636d280745 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class TemplateMapping { [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary Aliases { get; init; } [JsonInclude, JsonPropertyName("index_patterns")] public IReadOnlyCollection IndexPatterns { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs index c21918185ba..4f835d9ac41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs @@ -30,6 +30,5 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class TypeFieldMappings { [JsonInclude, JsonPropertyName("mappings")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Mapping.FieldMapping))] public IReadOnlyDictionary Mappings { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs index 39dafca28b2..e71c4353ff4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs @@ -27,12 +27,81 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propAllowNoIndices = default; + LocalJsonValue?> propExpandWildcards = default; + LocalJsonValue propIgnoreThrottled = default; + LocalJsonValue propIgnoreUnavailable = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryReadProperty(ref reader, options, PropAllowNoIndices, null)) + { + continue; + } + + if (propExpandWildcards.TryReadProperty(ref reader, options, PropExpandWildcards, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propIgnoreThrottled.TryReadProperty(ref reader, options, PropIgnoreThrottled, null)) + { + continue; + } + + if (propIgnoreUnavailable.TryReadProperty(ref reader, options, PropIgnoreUnavailable, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled, null, null); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable, null, null); + 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 +111,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 +120,6 @@ public sealed partial class IndicesOptions /// such as open,hidden. /// /// - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } /// @@ -61,7 +127,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 +134,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/_Generated/Types/Ingest/AppendProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs index b609af8460c..83bf89027bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAllowDuplicates = default; + LocalJsonValue propDescription = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + LocalJsonValue> propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowDuplicates.TryReadProperty(ref reader, options, PropAllowDuplicates, null)) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propIf.TryReadProperty(ref reader, options, PropIf, null)) + { + continue; + } + + if (propIgnoreFailure.TryReadProperty(ref reader, options, PropIgnoreFailure, null)) + { + continue; + } + + if (propOnFailure.TryReadProperty(ref reader, options, PropOnFailure, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTag.TryReadProperty(ref reader, options, PropTag, null)) + { + continue; + } + + if (propValue.TryReadProperty(ref reader, options, PropValue, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropIf, value.If, null, null); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure, null, null); + writer.WriteProperty(options, PropOnFailure, value.OnFailure, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTag, value.Tag, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AppendProcessorConverter))] public sealed partial class AppendProcessor { /// @@ -34,7 +143,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 +151,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 +159,6 @@ public sealed partial class AppendProcessor /// Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -60,7 +166,6 @@ public sealed partial class AppendProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -68,7 +173,6 @@ public sealed partial class AppendProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -76,7 +180,6 @@ public sealed partial class AppendProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -85,7 +188,6 @@ public sealed partial class AppendProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -93,8 +195,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.Ingest.Processor(AppendProcessor appendProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Append(appendProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs index a5d99c2209f..dae2c2443c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs @@ -27,6 +27,155 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDescription = default; + LocalJsonValue propEmptyValue = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propQuote = default; + LocalJsonValue propSeparator = default; + LocalJsonValue propTag = default; + LocalJsonValue propTargetFields = default; + LocalJsonValue propTrim = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propEmptyValue.TryReadProperty(ref reader, options, PropEmptyValue, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propIf.TryReadProperty(ref reader, options, PropIf, null)) + { + continue; + } + + if (propIgnoreFailure.TryReadProperty(ref reader, options, PropIgnoreFailure, null)) + { + continue; + } + + if (propIgnoreMissing.TryReadProperty(ref reader, options, PropIgnoreMissing, null)) + { + continue; + } + + if (propOnFailure.TryReadProperty(ref reader, options, PropOnFailure, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propQuote.TryReadProperty(ref reader, options, PropQuote, null)) + { + continue; + } + + if (propSeparator.TryReadProperty(ref reader, options, PropSeparator, null)) + { + continue; + } + + if (propTag.TryReadProperty(ref reader, options, PropTag, null)) + { + continue; + } + + if (propTargetFields.TryReadProperty(ref reader, options, PropTargetFields, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (propTrim.TryReadProperty(ref reader, options, PropTrim, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropEmptyValue, value.EmptyValue, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropIf, value.If, null, null); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure, null, null); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing, null, null); + writer.WriteProperty(options, PropOnFailure, value.OnFailure, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQuote, value.Quote, null, null); + writer.WriteProperty(options, PropSeparator, value.Separator, null, null); + writer.WriteProperty(options, PropTag, value.Tag, null, null); + writer.WriteProperty(options, PropTargetFields, value.TargetFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropTrim, value.Trim, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CsvProcessorConverter))] public sealed partial class CsvProcessor { /// @@ -35,7 +184,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 +193,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 +200,6 @@ public sealed partial class CsvProcessor /// The field to extract data from. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -61,7 +207,6 @@ public sealed partial class CsvProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -69,7 +214,6 @@ public sealed partial class CsvProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -77,7 +221,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 +228,6 @@ public sealed partial class CsvProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -93,7 +235,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 +242,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 +250,6 @@ public sealed partial class CsvProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -118,8 +257,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.Fields TargetFields { get; set; } /// @@ -127,7 +264,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.Ingest.Processor(CsvProcessor csvProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Csv(csvProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs index 0ee2cf7640a..e6b7c5d9ea8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs @@ -46,12 +46,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.Ingest.Ipinfo ipinfo) => new DatabaseConfiguration("ipinfo", ipinfo); public static DatabaseConfiguration Maxmind(Elastic.Clients.Elasticsearch.Ingest.Maxmind maxmind) => new DatabaseConfiguration("maxmind", maxmind); @@ -77,83 +81,76 @@ 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.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); + LocalJsonValue 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.TryReadProperty(ref reader, options, PropName, null)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") + if (reader.ValueTextEquals(VariantIpinfo)) { - nameValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "maxmind") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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) + switch (value.VariantType) { - writer.WritePropertyName("name"); - JsonSerializer.Serialize(writer, value.Name, options); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Maxmind)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo?)value.Variant, null, null); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Maxmind?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfiguration)}'."); } + writer.WriteProperty(options, PropName, value.Name, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs index 153f4bd724b..d43d0dad11c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs @@ -39,12 +39,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.Ingest.Ipinfo ipinfo) => new DatabaseConfigurationFull("ipinfo", ipinfo); public static DatabaseConfigurationFull Local(Elastic.Clients.Elasticsearch.Ingest.Local local) => new DatabaseConfigurationFull("local", local); @@ -72,103 +76,100 @@ 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); + LocalJsonValue 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.TryReadProperty(ref reader, options, PropName, null)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") + if (reader.ValueTextEquals(VariantIpinfo)) { - nameValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantLocal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLocal.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "local") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "maxmind") + if (reader.ValueTextEquals(VariantWeb)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeb.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "web") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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)) + switch (value.VariantType) { - writer.WritePropertyName("name"); - writer.WriteStringValue(value.Name); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo)value.Variant, options); - break; - case "local": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Local)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Maxmind)value.Variant, options); - break; - case "web": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Web)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo?)value.Variant, null, null); + break; + case "local": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Local?)value.Variant, null, null); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Maxmind?)value.Variant, null, null); + break; + case "web": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Web?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfigurationFull)}'."); } + writer.WriteProperty(options, PropName, value.Name, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs index 8d048ce6754..be981123e4f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs @@ -27,79 +27,109 @@ namespace Elastic.Clients.Elasticsearch.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 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.Ingest.IngestInfo ingest = default; - string? routing = default; - IReadOnlyDictionary source = default; - long? version = default; - Elastic.Clients.Elasticsearch.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; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIngest = default; + LocalJsonValue propRouting = default; + LocalJsonValue> propSource = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propId.TryReadProperty(ref reader, options, PropId, null)) { - 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.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIngest.TryReadProperty(ref reader, options, PropIngest, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static IReadOnlyDictionary (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)!)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (propVersionType.TryReadProperty(ref reader, options, PropVersionType, null)) + { + 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, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIngest, value.Ingest, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteProperty(options, PropVersionType, value.VersionType, null, null); + 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/_Generated/Types/Ingest/FingerprintProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs index 1242f11c013..8ec455dbeeb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs @@ -27,6 +27,135 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDescription = default; + LocalJsonValue propFields = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue propMethod = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propSalt = default; + LocalJsonValue propTag = default; + LocalJsonValue propTargetField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (propIf.TryReadProperty(ref reader, options, PropIf, null)) + { + continue; + } + + if (propIgnoreFailure.TryReadProperty(ref reader, options, PropIgnoreFailure, null)) + { + continue; + } + + if (propIgnoreMissing.TryReadProperty(ref reader, options, PropIgnoreMissing, null)) + { + continue; + } + + if (propMethod.TryReadProperty(ref reader, options, PropMethod, null)) + { + continue; + } + + if (propOnFailure.TryReadProperty(ref reader, options, PropOnFailure, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propSalt.TryReadProperty(ref reader, options, PropSalt, null)) + { + continue; + } + + if (propTag.TryReadProperty(ref reader, options, PropTag, null)) + { + continue; + } + + if (propTargetField.TryReadProperty(ref reader, options, PropTargetField, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropIf, value.If, null, null); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure, null, null); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing, null, null); + writer.WriteProperty(options, PropMethod, value.Method, null, null); + writer.WriteProperty(options, PropOnFailure, value.OnFailure, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSalt, value.Salt, null, null); + writer.WriteProperty(options, PropTag, value.Tag, null, null); + writer.WriteProperty(options, PropTargetField, value.TargetField, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FingerprintProcessorConverter))] public sealed partial class FingerprintProcessor { /// @@ -35,7 +164,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 +173,6 @@ public sealed partial class FingerprintProcessor /// only the field value. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// @@ -54,7 +180,6 @@ public sealed partial class FingerprintProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -62,7 +187,6 @@ public sealed partial class FingerprintProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -71,7 +195,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 +203,6 @@ public sealed partial class FingerprintProcessor /// SHA-256, SHA-512, or MurmurHash3. /// /// - [JsonInclude, JsonPropertyName("method")] public Elastic.Clients.Elasticsearch.Ingest.FingerprintDigest? Method { get; set; } /// @@ -88,7 +210,6 @@ public sealed partial class FingerprintProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -96,7 +217,6 @@ public sealed partial class FingerprintProcessor /// Salt value for the hash function. /// /// - [JsonInclude, JsonPropertyName("salt")] public string? Salt { get; set; } /// @@ -105,7 +225,6 @@ public sealed partial class FingerprintProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -113,7 +232,6 @@ public sealed partial class FingerprintProcessor /// Output field for the fingerprint. /// /// - [JsonInclude, JsonPropertyName("target_field")] public Elastic.Clients.Elasticsearch.Field? TargetField { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(FingerprintProcessor fingerprintProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Fingerprint(fingerprintProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs index ffa884fd3af..1a1a3072639 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs @@ -39,12 +39,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.Ingest.InferenceConfigClassification inferenceConfigClassification) => new InferenceConfig("classification", inferenceConfigClassification); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression inferenceConfigRegression) => new InferenceConfig("regression", inferenceConfigRegression); @@ -62,67 +66,61 @@ 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.Ingest.InferenceConfigClassification)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigClassification?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression?)value.Variant, null, null); + 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/_Generated/Types/Ingest/Processor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs index b7020c13d1a..f47c11361fd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs @@ -39,12 +39,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.Ingest.AppendProcessor appendProcessor) => new Processor("append", appendProcessor); public static Processor Attachment(Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor attachmentProcessor) => new Processor("attachment", attachmentProcessor); @@ -105,497 +109,577 @@ 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) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + 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(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."); + variantType = VariantAppend.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "append") + if (reader.ValueTextEquals(VariantAttachment)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAttachment.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "attachment") + if (reader.ValueTextEquals(VariantBytes)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBytes.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bytes") + if (reader.ValueTextEquals(VariantCircle)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCircle.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "circle") + if (reader.ValueTextEquals(VariantCommunityId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCommunityId.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "community_id") + if (reader.ValueTextEquals(VariantConvert)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConvert.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "convert") + if (reader.ValueTextEquals(VariantCsv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCsv.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "csv") + if (reader.ValueTextEquals(VariantDate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDate.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "date") + if (reader.ValueTextEquals(VariantDateIndexName)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateIndexName.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "date_index_name") + if (reader.ValueTextEquals(VariantDissect)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDissect.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "dissect") + if (reader.ValueTextEquals(VariantDotExpander)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDotExpander.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "dot_expander") + if (reader.ValueTextEquals(VariantDrop)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDrop.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "drop") + if (reader.ValueTextEquals(VariantEnrich)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantEnrich.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "enrich") + if (reader.ValueTextEquals(VariantFail)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFail.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fail") + if (reader.ValueTextEquals(VariantFingerprint)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFingerprint.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fingerprint") + if (reader.ValueTextEquals(VariantForeach)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantForeach.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "foreach") + if (reader.ValueTextEquals(VariantGeoGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoGrid.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_grid") + if (reader.ValueTextEquals(VariantGeoip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoip.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geoip") + if (reader.ValueTextEquals(VariantGrok)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGrok.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "grok") + if (reader.ValueTextEquals(VariantGsub)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGsub.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "gsub") + if (reader.ValueTextEquals(VariantHtmlStrip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHtmlStrip.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "html_strip") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantIpLocation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpLocation.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ip_location") + if (reader.ValueTextEquals(VariantJoin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJoin.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "join") + if (reader.ValueTextEquals(VariantJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJson.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "json") + if (reader.ValueTextEquals(VariantKv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKv.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "kv") + if (reader.ValueTextEquals(VariantLowercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLowercase.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "lowercase") + if (reader.ValueTextEquals(VariantNetworkDirection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNetworkDirection.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "network_direction") + if (reader.ValueTextEquals(VariantPipeline)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPipeline.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "pipeline") + if (reader.ValueTextEquals(VariantRedact)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRedact.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "redact") + if (reader.ValueTextEquals(VariantRegisteredDomain)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegisteredDomain.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "registered_domain") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRename)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRename.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rename") + if (reader.ValueTextEquals(VariantReroute)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReroute.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "reroute") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSet.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "set") + if (reader.ValueTextEquals(VariantSetSecurityUser)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSetSecurityUser.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "set_security_user") + if (reader.ValueTextEquals(VariantSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSort.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "sort") + if (reader.ValueTextEquals(VariantSplit)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSplit.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "split") + if (reader.ValueTextEquals(VariantTerminate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerminate.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "terminate") + if (reader.ValueTextEquals(VariantTrim)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTrim.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "trim") + if (reader.ValueTextEquals(VariantUppercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUppercase.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "uppercase") + if (reader.ValueTextEquals(VariantUriParts)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUriParts.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "uri_parts") + if (reader.ValueTextEquals(VariantUrlDecode)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUrlDecode.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "urldecode") + if (reader.ValueTextEquals(VariantUserAgent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUserAgent.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "user_agent") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.Ingest.AppendProcessor)value.Variant, options); - break; - case "attachment": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor)value.Variant, options); - break; - case "bytes": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.BytesProcessor)value.Variant, options); - break; - case "circle": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CircleProcessor)value.Variant, options); - break; - case "community_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CommunityIDProcessor)value.Variant, options); - break; - case "convert": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ConvertProcessor)value.Variant, options); - break; - case "csv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CsvProcessor)value.Variant, options); - break; - case "date": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DateProcessor)value.Variant, options); - break; - case "date_index_name": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DateIndexNameProcessor)value.Variant, options); - break; - case "dissect": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DissectProcessor)value.Variant, options); - break; - case "dot_expander": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DotExpanderProcessor)value.Variant, options); - break; - case "drop": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DropProcessor)value.Variant, options); - break; - case "enrich": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.EnrichProcessor)value.Variant, options); - break; - case "fail": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.FailProcessor)value.Variant, options); - break; - case "fingerprint": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.FingerprintProcessor)value.Variant, options); - break; - case "foreach": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ForeachProcessor)value.Variant, options); - break; - case "geo_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GeoGridProcessor)value.Variant, options); - break; - case "geoip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GeoIpProcessor)value.Variant, options); - break; - case "grok": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GrokProcessor)value.Variant, options); - break; - case "gsub": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GsubProcessor)value.Variant, options); - break; - case "html_strip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.HtmlStripProcessor)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.InferenceProcessor)value.Variant, options); - break; - case "ip_location": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.IpLocationProcessor)value.Variant, options); - break; - case "join": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.JoinProcessor)value.Variant, options); - break; - case "json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.JsonProcessor)value.Variant, options); - break; - case "kv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.KeyValueProcessor)value.Variant, options); - break; - case "lowercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.LowercaseProcessor)value.Variant, options); - break; - case "network_direction": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.NetworkDirectionProcessor)value.Variant, options); - break; - case "pipeline": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.PipelineProcessor)value.Variant, options); - break; - case "redact": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RedactProcessor)value.Variant, options); - break; - case "registered_domain": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RegisteredDomainProcessor)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RemoveProcessor)value.Variant, options); - break; - case "rename": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RenameProcessor)value.Variant, options); - break; - case "reroute": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RerouteProcessor)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ScriptProcessor)value.Variant, options); - break; - case "set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SetProcessor)value.Variant, options); - break; - case "set_security_user": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SetSecurityUserProcessor)value.Variant, options); - break; - case "sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SortProcessor)value.Variant, options); - break; - case "split": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SplitProcessor)value.Variant, options); - break; - case "terminate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.TerminateProcessor)value.Variant, options); - break; - case "trim": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.TrimProcessor)value.Variant, options); - break; - case "uppercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UppercaseProcessor)value.Variant, options); - break; - case "uri_parts": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UriPartsProcessor)value.Variant, options); - break; - case "urldecode": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UrlDecodeProcessor)value.Variant, options); - break; - case "user_agent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UserAgentProcessor)value.Variant, options); - break; - } + case "": + break; + case "append": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.AppendProcessor?)value.Variant, null, null); + break; + case "attachment": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor?)value.Variant, null, null); + break; + case "bytes": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.BytesProcessor?)value.Variant, null, null); + break; + case "circle": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CircleProcessor?)value.Variant, null, null); + break; + case "community_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CommunityIDProcessor?)value.Variant, null, null); + break; + case "convert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ConvertProcessor?)value.Variant, null, null); + break; + case "csv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CsvProcessor?)value.Variant, null, null); + break; + case "date": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DateProcessor?)value.Variant, null, null); + break; + case "date_index_name": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DateIndexNameProcessor?)value.Variant, null, null); + break; + case "dissect": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DissectProcessor?)value.Variant, null, null); + break; + case "dot_expander": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DotExpanderProcessor?)value.Variant, null, null); + break; + case "drop": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DropProcessor?)value.Variant, null, null); + break; + case "enrich": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.EnrichProcessor?)value.Variant, null, null); + break; + case "fail": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.FailProcessor?)value.Variant, null, null); + break; + case "fingerprint": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.FingerprintProcessor?)value.Variant, null, null); + break; + case "foreach": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ForeachProcessor?)value.Variant, null, null); + break; + case "geo_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GeoGridProcessor?)value.Variant, null, null); + break; + case "geoip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GeoIpProcessor?)value.Variant, null, null); + break; + case "grok": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GrokProcessor?)value.Variant, null, null); + break; + case "gsub": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GsubProcessor?)value.Variant, null, null); + break; + case "html_strip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.HtmlStripProcessor?)value.Variant, null, null); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceProcessor?)value.Variant, null, null); + break; + case "ip_location": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.IpLocationProcessor?)value.Variant, null, null); + break; + case "join": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.JoinProcessor?)value.Variant, null, null); + break; + case "json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.JsonProcessor?)value.Variant, null, null); + break; + case "kv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.KeyValueProcessor?)value.Variant, null, null); + break; + case "lowercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.LowercaseProcessor?)value.Variant, null, null); + break; + case "network_direction": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.NetworkDirectionProcessor?)value.Variant, null, null); + break; + case "pipeline": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.PipelineProcessor?)value.Variant, null, null); + break; + case "redact": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RedactProcessor?)value.Variant, null, null); + break; + case "registered_domain": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RegisteredDomainProcessor?)value.Variant, null, null); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RemoveProcessor?)value.Variant, null, null); + break; + case "rename": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RenameProcessor?)value.Variant, null, null); + break; + case "reroute": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RerouteProcessor?)value.Variant, null, null); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ScriptProcessor?)value.Variant, null, null); + break; + case "set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SetProcessor?)value.Variant, null, null); + break; + case "set_security_user": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SetSecurityUserProcessor?)value.Variant, null, null); + break; + case "sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SortProcessor?)value.Variant, null, null); + break; + case "split": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SplitProcessor?)value.Variant, null, null); + break; + case "terminate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.TerminateProcessor?)value.Variant, null, null); + break; + case "trim": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.TrimProcessor?)value.Variant, null, null); + break; + case "uppercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UppercaseProcessor?)value.Variant, null, null); + break; + case "uri_parts": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UriPartsProcessor?)value.Variant, null, null); + break; + case "urldecode": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UrlDecodeProcessor?)value.Variant, null, null); + break; + case "user_agent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UserAgentProcessor?)value.Variant, null, null); + 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/_Generated/Types/Ingest/RemoveProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs index 33124de7f4a..96e51ee4744 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDescription = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue propKeep = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (propIf.TryReadProperty(ref reader, options, PropIf, null)) + { + continue; + } + + if (propIgnoreFailure.TryReadProperty(ref reader, options, PropIgnoreFailure, null)) + { + continue; + } + + if (propIgnoreMissing.TryReadProperty(ref reader, options, PropIgnoreMissing, null)) + { + continue; + } + + if (propKeep.TryReadProperty(ref reader, options, PropKeep, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propOnFailure.TryReadProperty(ref reader, options, PropOnFailure, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTag.TryReadProperty(ref reader, options, PropTag, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropField, value.Field, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropIf, value.If, null, null); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure, null, null); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing, null, null); + writer.WriteProperty(options, PropKeep, value.Keep, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropOnFailure, value.OnFailure, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTag, value.Tag, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveProcessorConverter))] public sealed partial class RemoveProcessor { /// @@ -35,7 +144,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 +151,6 @@ public sealed partial class RemoveProcessor /// Fields to be removed. Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Field { get; set; } /// @@ -52,7 +158,6 @@ public sealed partial class RemoveProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -60,7 +165,6 @@ public sealed partial class RemoveProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -68,7 +172,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 +179,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.Fields? Keep { get; set; } /// @@ -85,7 +186,6 @@ public sealed partial class RemoveProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -94,7 +194,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.Ingest.Processor(RemoveProcessor removeProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Remove(removeProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs index 2f92c5c108e..a04eeee12ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propDataset = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDestination = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue?> propNamespace = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataset.TryReadProperty(ref reader, options, PropDataset, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propDescription.TryReadProperty(ref reader, options, PropDescription, null)) + { + continue; + } + + if (propDestination.TryReadProperty(ref reader, options, PropDestination, null)) + { + continue; + } + + if (propIf.TryReadProperty(ref reader, options, PropIf, null)) + { + continue; + } + + if (propIgnoreFailure.TryReadProperty(ref reader, options, PropIgnoreFailure, null)) + { + continue; + } + + if (propNamespace.TryReadProperty(ref reader, options, PropNamespace, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propOnFailure.TryReadProperty(ref reader, options, PropOnFailure, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propTag.TryReadProperty(ref reader, options, PropTag, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropDescription, value.Description, null, null); + writer.WriteProperty(options, PropDestination, value.Destination, null, null); + writer.WriteProperty(options, PropIf, value.If, null, null); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure, null, null); + writer.WriteProperty(options, PropNamespace, value.Namespace, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropOnFailure, value.OnFailure, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropTag, value.Tag, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RerouteProcessorConverter))] public sealed partial class RerouteProcessor { /// @@ -44,8 +153,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.dataset}} /// /// - [JsonInclude, JsonPropertyName("dataset")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Dataset { get; set; } /// @@ -54,7 +161,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 +168,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 +175,6 @@ public sealed partial class RerouteProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -78,7 +182,6 @@ public sealed partial class RerouteProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -95,8 +198,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.namespace}} /// /// - [JsonInclude, JsonPropertyName("namespace")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Namespace { get; set; } /// @@ -104,7 +205,6 @@ public sealed partial class RerouteProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -113,7 +213,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.Ingest.Processor(RerouteProcessor rerouteProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Reroute(rerouteProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs index 8a7a7d95cd3..c9e40599ad8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs @@ -27,76 +27,120 @@ namespace Elastic.Clients.Elasticsearch; -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 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; + LocalJsonValue?> propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFields.TryReadProperty(ref reader, options, PropFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propFound.TryReadProperty(ref reader, options, PropFound, null)) + { + continue; + } + + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, null)) + { + continue; + } + + if (propSource.TryReadProperty(ref reader, options, PropSource, static TDocument? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropFound, value.Found, null, null); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, null); + writer.WriteProperty(options, PropSource, value.Source, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, TDocument? v) => w.WriteValueEx(o, v, 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/_Generated/Types/KnnQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs index 8ef6b7429e7..9d0fc096609 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs @@ -27,6 +27,125 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propk = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue propQueryName = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propk.TryReadProperty(ref reader, options, Propk, null)) + { + continue; + } + + if (propNumCandidates.TryReadProperty(ref reader, options, PropNumCandidates, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propQueryVector.TryReadProperty(ref reader, options, PropQueryVector, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propQueryVectorBuilder.TryReadProperty(ref reader, options, PropQueryVectorBuilder, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, Propk, value.k, null, null); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropQueryVector, value.QueryVector, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnQueryConverter))] public sealed partial class KnnQuery { /// @@ -37,7 +156,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 +163,6 @@ public sealed partial class KnnQuery /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -53,8 +170,6 @@ public sealed partial class KnnQuery /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -62,7 +177,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 +184,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 +192,6 @@ public sealed partial class KnnQuery /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -88,7 +199,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.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -96,7 +206,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.QueryDsl.Query(KnnQuery knnQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.Knn(knnQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs index effdb6f24c5..2a333670d7e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs @@ -27,6 +27,115 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propk = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propk.TryReadProperty(ref reader, options, Propk, null)) + { + continue; + } + + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } + + if (propNumCandidates.TryReadProperty(ref reader, options, PropNumCandidates, null)) + { + continue; + } + + if (propQueryVector.TryReadProperty(ref reader, options, PropQueryVector, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propQueryVectorBuilder.TryReadProperty(ref reader, options, PropQueryVectorBuilder, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, Propk, value.k, null, null); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates, null, null); + writer.WriteProperty(options, PropQueryVector, value.QueryVector, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnRetrieverConverter))] public sealed partial class KnnRetriever { /// @@ -34,7 +143,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 +150,6 @@ public sealed partial class KnnRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -51,7 +157,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 +164,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 +171,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 +178,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 +185,6 @@ public sealed partial class KnnRetriever /// Defines a model to build a query vector. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -91,7 +192,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.Retriever(KnnRetriever knnRetriever) => Elastic.Clients.Elasticsearch.Retriever.Knn(knnRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs index a3a664f8101..ec0d0d353a5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs @@ -27,6 +27,125 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propInnerHits = default; + LocalJsonValue propk = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propInnerHits.TryReadProperty(ref reader, options, PropInnerHits, null)) + { + continue; + } + + if (propk.TryReadProperty(ref reader, options, Propk, null)) + { + continue; + } + + if (propNumCandidates.TryReadProperty(ref reader, options, PropNumCandidates, null)) + { + continue; + } + + if (propQueryVector.TryReadProperty(ref reader, options, PropQueryVector, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propQueryVectorBuilder.TryReadProperty(ref reader, options, PropQueryVectorBuilder, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropInnerHits, value.InnerHits, null, null); + writer.WriteProperty(options, Propk, value.k, null, null); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates, null, null); + writer.WriteProperty(options, PropQueryVector, value.QueryVector, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnSearchConverter))] public sealed partial class KnnSearch { /// @@ -34,7 +153,6 @@ public sealed partial class KnnSearch /// Boost value to apply to kNN scores /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -42,7 +160,6 @@ public sealed partial class KnnSearch /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -50,8 +167,6 @@ public sealed partial class KnnSearch /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -59,7 +174,6 @@ public sealed partial class KnnSearch /// If defined, each search hit will contain inner hits. /// /// - [JsonInclude, JsonPropertyName("inner_hits")] public Elastic.Clients.Elasticsearch.Core.Search.InnerHits? InnerHits { get; set; } /// @@ -67,7 +181,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 +188,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 +195,6 @@ public sealed partial class KnnSearch /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -91,7 +202,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.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -99,7 +209,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/_Generated/Types/MachineLearning/AnalysisConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs index 317b1ad5cbb..b8fcd036097 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs @@ -76,7 +76,6 @@ public sealed partial class AnalysisConfig /// /// [JsonInclude, JsonPropertyName("influencers")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Influencers { get; set; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/CategorizationAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/CategorizationAnalyzer.g.cs index 24508aef8fe..5dc503fb99b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/CategorizationAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/CategorizationAnalyzer.g.cs @@ -30,13 +30,52 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; +[JsonConverter(typeof(CategorizationAnalyzerConverter))] public sealed partial class CategorizationAnalyzer : Union { - public CategorizationAnalyzer(string Name) : base(Name) + public CategorizationAnalyzer(string name) : base(name) { } - public CategorizationAnalyzer(Elastic.Clients.Elasticsearch.MachineLearning.CategorizationAnalyzerDefinition Definition) : base(Definition) + public CategorizationAnalyzer(Elastic.Clients.Elasticsearch.MachineLearning.CategorizationAnalyzerDefinition definition) : base(definition) { } + + public static implicit operator CategorizationAnalyzer(string name) => new CategorizationAnalyzer(name); + public static implicit operator CategorizationAnalyzer(Elastic.Clients.Elasticsearch.MachineLearning.CategorizationAnalyzerDefinition definition) => new CategorizationAnalyzer(definition); +} + +internal sealed partial class CategorizationAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + public override CategorizationAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new CategorizationAnalyzer(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new CategorizationAnalyzer(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(CategorizationAnalyzer)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CategorizationAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs index 399bbc72bc7..c6d14aeb5ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs @@ -27,137 +27,192 @@ namespace Elastic.Clients.Elasticsearch.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.MachineLearning.DatafeedAuthorization? authorization = default; - Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? chunkingConfig = default; - string datafeedId = default; - Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig delayedDataCheckConfig = default; - Elastic.Clients.Elasticsearch.Duration? frequency = default; - IReadOnlyCollection? indexes = default; - IReadOnlyCollection indices = default; - Elastic.Clients.Elasticsearch.IndicesOptions? indicesOptions = default; - string jobId = default; - int? maxEmptySearches = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query query = default; - Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue?> propIndexes = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue 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.TryReadProperty(ref reader, options, PropAggregations, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propAuthorization.TryReadProperty(ref reader, options, PropAuthorization, null)) + { + continue; + } + + if (propChunkingConfig.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + continue; + } + + if (propDatafeedId.TryReadProperty(ref reader, options, PropDatafeedId, null)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; } + + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } + + if (propIndexes.TryReadProperty(ref reader, options, PropIndexes, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } + + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } + + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } + + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropAuthorization, value.Authorization, null, null); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropIndexes, value.Indexes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndices, value.Indices, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs index 0402dcefb43..b2cda1d2309 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs @@ -27,194 +27,172 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null)) || propAggregations.TryReadProperty(ref reader, options, PropAggregations1, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) { - 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.TryReadProperty(ref reader, options, PropChunkingConfig, null)) + { + 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.TryReadProperty(ref reader, options, PropDatafeedId, null)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propDelayedDataCheckConfig.TryReadProperty(ref reader, options, PropDelayedDataCheckConfig, null)) + { + continue; + } - if (value.DatafeedId is not null) - { - writer.WritePropertyName("datafeed_id"); - JsonSerializer.Serialize(writer, value.DatafeedId, options); - } + if (propFrequency.TryReadProperty(ref reader, options, PropFrequency, null)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null) || propIndices.TryReadProperty(ref reader, options, PropIndices1, null)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryReadProperty(ref reader, options, PropIndicesOptions, null)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryReadProperty(ref reader, options, PropJobId, null)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryReadProperty(ref reader, options, PropMaxEmptySearches, null)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryReadProperty(ref reader, options, PropQueryDelay, null)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryReadProperty(ref reader, options, PropRuntimeMappings, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryReadProperty(ref reader, options, PropScriptFields, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryReadProperty(ref reader, options, PropScrollSize, null)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig, null, null); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId, null, null); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig, null, null); + writer.WriteProperty(options, PropFrequency, value.Frequency, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions, null, null); + writer.WriteProperty(options, PropJobId, value.JobId, null, null); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay, null, null); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs index f7a17f76691..3bd0640cfa8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs @@ -39,12 +39,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.MachineLearning.DataframeAnalysisClassification dataframeAnalysisClassification) => new DataframeAnalysis("classification", dataframeAnalysisClassification); public static DataframeAnalysis OutlierDetection(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection dataframeAnalysisOutlierDetection) => new DataframeAnalysis("outlier_detection", dataframeAnalysisOutlierDetection); @@ -63,77 +67,73 @@ 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.DataframeAnalysisClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisClassification?)value.Variant, null, null); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisRegression?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs index 0ceb9b0f4e9..cee8209535b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs @@ -27,6 +27,61 @@ namespace Elastic.Clients.Elasticsearch.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, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!); + return new DataframeAnalysisAnalyzedFields { Includes = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propExcludes = default; + LocalJsonValue> propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExcludes.TryReadProperty(ref reader, options, PropExcludes, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propIncludes.TryReadProperty(ref reader, options, PropIncludes, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIncludes, value.Includes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataframeAnalysisAnalyzedFieldsConverter))] public sealed partial class DataframeAnalysisAnalyzedFields { /// @@ -34,7 +89,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 +96,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/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs index 06504695f4c..8fc5605a92c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs @@ -27,262 +27,231 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAlpha = default; + LocalJsonValue propClassAssignmentObjective = default; + LocalJsonValue propDependentVariable = default; + LocalJsonValue propDownsampleFactor = default; + LocalJsonValue propEarlyStoppingEnabled = default; + LocalJsonValue propEta = default; + LocalJsonValue propEtaGrowthRatePerTree = default; + LocalJsonValue propFeatureBagFraction = default; + LocalJsonValue?> propFeatureProcessors = default; + LocalJsonValue propGamma = default; + LocalJsonValue propLambda = default; + LocalJsonValue propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonValue propMaxTrees = default; + LocalJsonValue propNumTopClasses = default; + LocalJsonValue propNumTopFeatureImportanceValues = default; + LocalJsonValue propPredictionFieldName = default; + LocalJsonValue propRandomizeSeed = default; + LocalJsonValue propSoftTreeDepthLimit = default; + LocalJsonValue propSoftTreeDepthTolerance = default; + LocalJsonValue propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryReadProperty(ref reader, options, PropAlpha, null)) { - 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.TryReadProperty(ref reader, options, PropClassAssignmentObjective, null)) + { + 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.TryReadProperty(ref reader, options, PropDependentVariable, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.ClassAssignmentObjective)) - { - writer.WritePropertyName("class_assignment_objective"); - writer.WriteStringValue(value.ClassAssignmentObjective); - } + if (propDownsampleFactor.TryReadProperty(ref reader, options, PropDownsampleFactor, null)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryReadProperty(ref reader, options, PropEarlyStoppingEnabled, null)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryReadProperty(ref reader, options, PropEta, null)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryReadProperty(ref reader, options, PropEtaGrowthRatePerTree, null)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryReadProperty(ref reader, options, PropFeatureBagFraction, null)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryReadProperty(ref reader, options, PropFeatureProcessors, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryReadProperty(ref reader, options, PropGamma, null)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryReadProperty(ref reader, options, PropLambda, null)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryReadProperty(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter, null)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryReadProperty(ref reader, options, PropMaxTrees, null) || propMaxTrees.TryReadProperty(ref reader, options, PropMaxTrees1, null)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopClasses.TryReadProperty(ref reader, options, PropNumTopClasses, null)) + { + continue; + } - if (value.NumTopClasses.HasValue) - { - writer.WritePropertyName("num_top_classes"); - writer.WriteNumberValue(value.NumTopClasses.Value); - } + if (propNumTopFeatureImportanceValues.TryReadProperty(ref reader, options, PropNumTopFeatureImportanceValues, null)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryReadProperty(ref reader, options, PropPredictionFieldName, null)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryReadProperty(ref reader, options, PropRandomizeSeed, null)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryReadProperty(ref reader, options, PropSoftTreeDepthLimit, null)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryReadProperty(ref reader, options, PropSoftTreeDepthTolerance, null)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryReadProperty(ref reader, options, PropTrainingPercent, null)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropClassAssignmentObjective, value.ClassAssignmentObjective, null, null); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable, null, null); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor, null, null); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled, null, null); + writer.WriteProperty(options, PropEta, value.Eta, null, null); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree, null, null); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction, null, null); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropGamma, value.Gamma, null, null); + writer.WriteProperty(options, PropLambda, value.Lambda, null, null); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter, null, null); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees, null, null); + writer.WriteProperty(options, PropNumTopClasses, value.NumTopClasses, null, null); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues, null, null); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName, null, null); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed, null, null); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit, null, null); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance, null, null); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs index 68a0de314d1..c07417f8626 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs @@ -39,12 +39,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.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding dataframeAnalysisFeatureProcessorFrequencyEncoding) => new DataframeAnalysisFeatureProcessor("frequency_encoding", dataframeAnalysisFeatureProcessorFrequencyEncoding); public static DataframeAnalysisFeatureProcessor MultiEncoding(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding dataframeAnalysisFeatureProcessorMultiEncoding) => new DataframeAnalysisFeatureProcessor("multi_encoding", dataframeAnalysisFeatureProcessorMultiEncoding); @@ -65,97 +69,97 @@ 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."); + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") + if (reader.ValueTextEquals(VariantMultiEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "multi_encoding") + if (reader.ValueTextEquals(VariantNGramEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNGramEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "n_gram_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "target_mean_encoding") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding)value.Variant, options); - break; - case "multi_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding)value.Variant, options); - break; - case "n_gram_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding?)value.Variant, null, null); + break; + case "multi_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding?)value.Variant, null, null); + break; + case "n_gram_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding?)value.Variant, null, null); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding?)value.Variant, null, null); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs index 33f1f359972..043517a5fef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs @@ -27,262 +27,231 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAlpha = default; + LocalJsonValue propDependentVariable = default; + LocalJsonValue propDownsampleFactor = default; + LocalJsonValue propEarlyStoppingEnabled = default; + LocalJsonValue propEta = default; + LocalJsonValue propEtaGrowthRatePerTree = default; + LocalJsonValue propFeatureBagFraction = default; + LocalJsonValue?> propFeatureProcessors = default; + LocalJsonValue propGamma = default; + LocalJsonValue propLambda = default; + LocalJsonValue propLossFunction = default; + LocalJsonValue propLossFunctionParameter = default; + LocalJsonValue propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonValue propMaxTrees = default; + LocalJsonValue propNumTopFeatureImportanceValues = default; + LocalJsonValue propPredictionFieldName = default; + LocalJsonValue propRandomizeSeed = default; + LocalJsonValue propSoftTreeDepthLimit = default; + LocalJsonValue propSoftTreeDepthTolerance = default; + LocalJsonValue propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryReadProperty(ref reader, options, PropAlpha, null)) { - 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.TryReadProperty(ref reader, options, PropDependentVariable, null)) + { + 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.TryReadProperty(ref reader, options, PropDownsampleFactor, null)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryReadProperty(ref reader, options, PropEarlyStoppingEnabled, null)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryReadProperty(ref reader, options, PropEta, null)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryReadProperty(ref reader, options, PropEtaGrowthRatePerTree, null)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryReadProperty(ref reader, options, PropFeatureBagFraction, null)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryReadProperty(ref reader, options, PropFeatureProcessors, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryReadProperty(ref reader, options, PropGamma, null)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryReadProperty(ref reader, options, PropLambda, null)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propLossFunction.TryReadProperty(ref reader, options, PropLossFunction, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.LossFunction)) - { - writer.WritePropertyName("loss_function"); - writer.WriteStringValue(value.LossFunction); - } + if (propLossFunctionParameter.TryReadProperty(ref reader, options, PropLossFunctionParameter, null)) + { + continue; + } - if (value.LossFunctionParameter.HasValue) - { - writer.WritePropertyName("loss_function_parameter"); - writer.WriteNumberValue(value.LossFunctionParameter.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryReadProperty(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter, null)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryReadProperty(ref reader, options, PropMaxTrees, null) || propMaxTrees.TryReadProperty(ref reader, options, PropMaxTrees1, null)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopFeatureImportanceValues.TryReadProperty(ref reader, options, PropNumTopFeatureImportanceValues, null)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryReadProperty(ref reader, options, PropPredictionFieldName, null)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryReadProperty(ref reader, options, PropRandomizeSeed, null)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryReadProperty(ref reader, options, PropSoftTreeDepthLimit, null)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryReadProperty(ref reader, options, PropSoftTreeDepthTolerance, null)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryReadProperty(ref reader, options, PropTrainingPercent, null)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable, null, null); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor, null, null); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled, null, null); + writer.WriteProperty(options, PropEta, value.Eta, null, null); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree, null, null); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction, null, null); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropGamma, value.Gamma, null, null); + writer.WriteProperty(options, PropLambda, value.Lambda, null, null); + writer.WriteProperty(options, PropLossFunction, value.LossFunction, null, null); + writer.WriteProperty(options, PropLossFunctionParameter, value.LossFunctionParameter, null, null); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter, null, null); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees, null, null); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues, null, null); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName, null, null); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed, null, null); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit, null, null); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance, null, null); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs index 28d0462487e..85e070d4748 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs @@ -39,12 +39,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.MachineLearning.DataframeEvaluationClassification dataframeEvaluationClassification) => new DataframeEvaluation("classification", dataframeEvaluationClassification); public static DataframeEvaluation OutlierDetection(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection dataframeEvaluationOutlierDetection) => new DataframeEvaluation("outlier_detection", dataframeEvaluationOutlierDetection); @@ -63,77 +67,73 @@ 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.DataframeEvaluationClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassification?)value.Variant, null, null); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationRegression?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs index 7521192e9fc..ff6d5c0e750 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs @@ -44,12 +44,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.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigCreate("classification", classificationInferenceOptions); public static InferenceConfigCreate FillMask(Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions fillMaskInferenceOptions) => new InferenceConfigCreate("fill_mask", fillMaskInferenceOptions); @@ -75,147 +79,157 @@ 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) + 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "zero_shot_classification") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant, null, null); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions?)value.Variant, null, null); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceOptions?)value.Variant, null, null); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceOptions?)value.Variant, null, null); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceOptions?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant, null, null); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceOptions?)value.Variant, null, null); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceOptions?)value.Variant, null, null); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceOptions?)value.Variant, null, null); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceOptions?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs index fea26716443..8d7b1adbfda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs @@ -39,12 +39,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.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigUpdate("classification", classificationInferenceOptions); public static InferenceConfigUpdate FillMask(Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions fillMaskInferenceUpdateOptions) => new InferenceConfigUpdate("fill_mask", fillMaskInferenceUpdateOptions); @@ -70,147 +74,157 @@ 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) + 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."); + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "zero_shot_classification") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceUpdateOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceUpdateOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceUpdateOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceUpdateOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceUpdateOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceUpdateOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceUpdateOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant, null, null); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions?)value.Variant, null, null); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceUpdateOptions?)value.Variant, null, null); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceUpdateOptions?)value.Variant, null, null); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceUpdateOptions?)value.Variant, null, null); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant, null, null); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceUpdateOptions?)value.Variant, null, null); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceUpdateOptions?)value.Variant, null, null); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceUpdateOptions?)value.Variant, null, null); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceUpdateOptions?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs index afa959c72f1..2b94ce9d1d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs @@ -27,6 +27,125 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propEntities = default; + LocalJsonValue?> propFeatureImportance = default; + LocalJsonValue propIsTruncated = default; + LocalJsonValue?> propPredictedValue = default; + LocalJsonValue propPredictedValueSequence = default; + LocalJsonValue propPredictionProbability = default; + LocalJsonValue propPredictionScore = default; + LocalJsonValue?> propTopClasses = default; + LocalJsonValue propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEntities.TryReadProperty(ref reader, options, PropEntities, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propFeatureImportance.TryReadProperty(ref reader, options, PropFeatureImportance, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propIsTruncated.TryReadProperty(ref reader, options, PropIsTruncated, null)) + { + continue; + } + + if (propPredictedValue.TryReadProperty(ref reader, options, PropPredictedValue, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propPredictedValueSequence.TryReadProperty(ref reader, options, PropPredictedValueSequence, null)) + { + continue; + } + + if (propPredictionProbability.TryReadProperty(ref reader, options, PropPredictionProbability, null)) + { + continue; + } + + if (propPredictionScore.TryReadProperty(ref reader, options, PropPredictionScore, null)) + { + continue; + } + + if (propTopClasses.TryReadProperty(ref reader, options, PropTopClasses, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propWarning.TryReadProperty(ref reader, options, PropWarning, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropFeatureImportance, value.FeatureImportance, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropIsTruncated, value.IsTruncated, null, null); + writer.WriteProperty(options, PropPredictedValue, value.PredictedValue, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPredictedValueSequence, value.PredictedValueSequence, null, null); + writer.WriteProperty(options, PropPredictionProbability, value.PredictionProbability, null, null); + writer.WriteProperty(options, PropPredictionScore, value.PredictionScore, null, null); + writer.WriteProperty(options, PropTopClasses, value.TopClasses, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropWarning, value.Warning, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferenceResponseResultConverter))] public sealed partial class InferenceResponseResult { /// @@ -34,7 +153,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 +160,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 +168,6 @@ public sealed partial class InferenceResponseResult /// is present only when it is true. /// /// - [JsonInclude, JsonPropertyName("is_truncated")] public bool? IsTruncated { get; init; } /// @@ -65,8 +181,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 +190,6 @@ public sealed partial class InferenceResponseResult /// Additionally /// /// - [JsonInclude, JsonPropertyName("predicted_value_sequence")] public string? PredictedValueSequence { get; init; } /// @@ -84,7 +197,6 @@ public sealed partial class InferenceResponseResult /// Specifies a probability for the predicted value. /// /// - [JsonInclude, JsonPropertyName("prediction_probability")] public double? PredictionProbability { get; init; } /// @@ -92,7 +204,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 +212,6 @@ public sealed partial class InferenceResponseResult /// class entries. /// /// - [JsonInclude, JsonPropertyName("top_classes")] public IReadOnlyCollection? TopClasses { get; init; } /// @@ -109,6 +219,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/_Generated/Types/MachineLearning/Preprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs index c20929f486d..91920e5970b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs @@ -39,12 +39,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.MachineLearning.FrequencyEncodingPreprocessor frequencyEncodingPreprocessor) => new Preprocessor("frequency_encoding", frequencyEncodingPreprocessor); public static Preprocessor OneHotEncoding(Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor oneHotEncodingPreprocessor) => new Preprocessor("one_hot_encoding", oneHotEncodingPreprocessor); @@ -63,77 +67,73 @@ 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."); + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "target_mean_encoding") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.FrequencyEncodingPreprocessor)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TargetMeanEncodingPreprocessor)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FrequencyEncodingPreprocessor?)value.Variant, null, null); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor?)value.Variant, null, null); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TargetMeanEncodingPreprocessor?)value.Variant, null, null); + 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/_Generated/Types/MachineLearning/TokenizationConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs index e3dc630aebf..a2ca2aba5d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs @@ -44,12 +44,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.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert", nlpBertTokenizationConfig); public static TokenizationConfig BertJa(Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert_ja", nlpBertTokenizationConfig); @@ -69,87 +73,85 @@ 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."); + variantType = VariantBert.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bert") + if (reader.ValueTextEquals(VariantBertJa)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBertJa.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "bert_ja") + if (reader.ValueTextEquals(VariantMpnet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMpnet.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "mpnet") + if (reader.ValueTextEquals(VariantRoberta)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRoberta.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "roberta") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "bert_ja": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "mpnet": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "roberta": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpRobertaTokenizationConfig)value.Variant, options); - break; - } + case "": + break; + case "bert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant, null, null); + break; + case "bert_ja": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant, null, null); + break; + case "mpnet": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant, null, null); + break; + case "roberta": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpRobertaTokenizationConfig?)value.Variant, null, null); + 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/_Generated/Types/Mapping/BinaryProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs index a27bb3c9071..01ccf6df355 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs @@ -27,18 +27,129 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BinaryPropertyConverter))] public sealed partial class BinaryProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +157,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.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/_Generated/Types/Mapping/BooleanProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs index f0f377e59a1..eda196a4f4b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs @@ -27,24 +27,172 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFielddata.TryReadProperty(ref reader, options, PropFielddata, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFielddata, value.Fielddata, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,16 +200,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.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/_Generated/Types/Mapping/ByteNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs index 71d104cab4c..7bbf857909b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 ByteNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class ByteNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class ByteNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "byte"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs index c0074fde8a4..5a506551189 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs @@ -27,24 +27,192 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue?> propContexts = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propMaxInputLength = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPreservePositionIncrements = default; + LocalJsonValue propPreserveSeparators = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propContexts.TryReadProperty(ref reader, options, PropContexts, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMaxInputLength.TryReadProperty(ref reader, options, PropMaxInputLength, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propPreservePositionIncrements.TryReadProperty(ref reader, options, PropPreservePositionIncrements, null)) + { + continue; + } + + if (propPreserveSeparators.TryReadProperty(ref reader, options, PropPreserveSeparators, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propSearchAnalyzer.TryReadProperty(ref reader, options, PropSearchAnalyzer, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropContexts, value.Contexts, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMaxInputLength, value.MaxInputLength, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropPreservePositionIncrements, value.PreservePositionIncrements, null, null); + writer.WriteProperty(options, PropPreserveSeparators, value.PreserveSeparators, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +220,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.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/_Generated/Types/Mapping/DateNanosProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs index fab89d7abb4..da0582580ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs @@ -27,26 +27,193 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propPrecisionStep.TryReadProperty(ref reader, options, PropPrecisionStep, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +221,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.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/_Generated/Types/Mapping/DateProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs index 39b0ac3fdaa..805cae5fd97 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs @@ -27,30 +27,215 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue propLocale = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFielddata.TryReadProperty(ref reader, options, PropFielddata, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propLocale.TryReadProperty(ref reader, options, PropLocale, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propPrecisionStep.TryReadProperty(ref reader, options, PropPrecisionStep, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFielddata, value.Fielddata, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropLocale, value.Locale, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +243,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.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/_Generated/Types/Mapping/DateRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs index bb5b8d54471..52d1ed9c4a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs @@ -27,26 +27,173 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +201,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.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/_Generated/Types/Mapping/DoubleNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs index 923e630d9fa..730ad5f1d51 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 DoubleNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class DoubleNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class DoubleNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "double"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs index 4c0c6868967..696cc742a23 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs @@ -27,24 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +190,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.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/_Generated/Types/Mapping/DynamicProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs index e44d585e58d..ba019e84053 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs @@ -27,42 +27,361 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propIndexPhrases = default; + LocalJsonValue propIndexPrefixes = default; + LocalJsonValue propLocale = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryReadProperty(ref reader, options, PropEagerGlobalOrdinals, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null)) + { + continue; + } + + if (propIndexPhrases.TryReadProperty(ref reader, options, PropIndexPhrases, null)) + { + continue; + } + + if (propIndexPrefixes.TryReadProperty(ref reader, options, PropIndexPrefixes, null)) + { + continue; + } + + if (propLocale.TryReadProperty(ref reader, options, PropLocale, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNorms.TryReadProperty(ref reader, options, PropNorms, null)) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propPositionIncrementGap.TryReadProperty(ref reader, options, PropPositionIncrementGap, null)) + { + continue; + } + + if (propPrecisionStep.TryReadProperty(ref reader, options, PropPrecisionStep, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propSearchAnalyzer.TryReadProperty(ref reader, options, PropSearchAnalyzer, null)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryReadProperty(ref reader, options, PropSearchQuoteAnalyzer, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTermVector.TryReadProperty(ref reader, options, PropTermVector, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases, null, null); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes, null, null); + writer.WriteProperty(options, PropLocale, value.Locale, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNorms, value.Norms, null, null); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap, null, null); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer, null, null); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTermVector, value.TermVector, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.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.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.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } - [JsonInclude, JsonPropertyName("locale")] public string? Locale { get; set; } /// @@ -70,34 +389,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.FieldValue? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.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.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.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.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "{dynamic_type}"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs index fa40241afaa..4edc055acd8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs @@ -39,12 +39,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.Mapping.IProperty property) => new DynamicTemplate("mapping", property); public static DynamicTemplate Runtime(Elastic.Clients.Elasticsearch.Mapping.IProperty property) => new DynamicTemplate("runtime", property); @@ -77,167 +81,136 @@ 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.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); + LocalJsonValue?> propMatch = default; + LocalJsonValue?> propMatchMappingType = default; + LocalJsonValue propMatchPattern = default; + LocalJsonValue?> propPathMatch = default; + LocalJsonValue?> propPathUnmatch = default; + LocalJsonValue?> propUnmatch = default; + LocalJsonValue?> 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) + if (propMatch.TryReadProperty(ref reader, options, PropMatch, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - 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 == "match") + if (propMatchMappingType.TryReadProperty(ref reader, options, PropMatchMappingType, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - matchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_mapping_type") + if (propMatchPattern.TryReadProperty(ref reader, options, PropMatchPattern, null)) { - matchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_pattern") + if (propPathMatch.TryReadProperty(ref reader, options, PropPathMatch, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - matchPatternValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "path_match") + if (propPathUnmatch.TryReadProperty(ref reader, options, PropPathUnmatch, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - pathMatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "path_unmatch") + if (propUnmatch.TryReadProperty(ref reader, options, PropUnmatch, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - pathUnmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch") + if (propUnmatchMappingType.TryReadProperty(ref reader, options, PropUnmatchMappingType, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) { - unmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch_mapping_type") + if (reader.ValueTextEquals(VariantMapping)) { - unmatchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); + variantType = VariantMapping.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "mapping") + if (reader.ValueTextEquals(VariantRuntime)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRuntime.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "runtime") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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) - { - 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) + switch (value.VariantType) { - 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.Mapping.IProperty)value.Variant, options); - break; - case "runtime": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Mapping.IProperty)value.Variant, options); - break; - } + case "": + break; + case "mapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Mapping.IProperty?)value.Variant, null, null); + break; + case "runtime": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Mapping.IProperty?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DynamicTemplate)}'."); } + writer.WriteProperty(options, PropMatch, value.Match, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMatchMappingType, value.MatchMappingType, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMatchPattern, value.MatchPattern, null, null); + writer.WriteProperty(options, PropPathMatch, value.PathMatch, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPathUnmatch, value.PathUnmatch, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropUnmatch, value.Unmatch, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropUnmatchMappingType, value.UnmatchMappingType, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs index 78b51afb62b..47bbde99e6f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 FloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class FloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class FloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs index baba3f12be0..414ae2c0c46 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs @@ -27,24 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +190,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.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/_Generated/Types/Mapping/GeoPointProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs index 8151792a3a9..2f112a40578 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs @@ -27,24 +27,192 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIgnoreZValue.TryReadProperty(ref reader, options, PropIgnoreZValue, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoPointPropertyConverter))] public sealed partial class GeoPointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +220,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.GeoLocation? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Mapping/GeoShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs index 0563e2b83b6..6b362aca2d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs @@ -27,6 +27,172 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propOrientation = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propStrategy = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIgnoreZValue.TryReadProperty(ref reader, options, PropIgnoreZValue, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propOrientation.TryReadProperty(ref reader, options, PropOrientation, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propStrategy.TryReadProperty(ref reader, options, PropStrategy, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropOrientation, value.Orientation, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropStrategy, value.Strategy, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + /// /// /// The geo_shape data type facilitates the indexing of and searching with arbitrary geo shapes such as rectangles @@ -34,24 +200,16 @@ namespace Elastic.Clients.Elasticsearch.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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +217,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.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("strategy")] public Elastic.Clients.Elasticsearch.Mapping.GeoStrategy? Strategy { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "geo_shape"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs index 5dadc17bb15..e2e2c68db95 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 HalfFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "half_float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs index 5acfa164441..9be62e4d9e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs @@ -27,30 +27,295 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAlternate = default; + LocalJsonValue propCaseFirst = default; + LocalJsonValue propCaseLevel = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propCountry = default; + LocalJsonValue propDecomposition = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propHiraganaQuaternaryMode = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propLanguage = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propNumeric = default; + LocalJsonValue propProperties = default; + LocalJsonValue propRules = default; + LocalJsonValue propStore = default; + LocalJsonValue propStrength = default; + LocalJsonValue propVariableTop = default; + LocalJsonValue propVariant = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlternate.TryReadProperty(ref reader, options, PropAlternate, null)) + { + continue; + } + + if (propCaseFirst.TryReadProperty(ref reader, options, PropCaseFirst, null)) + { + continue; + } + + if (propCaseLevel.TryReadProperty(ref reader, options, PropCaseLevel, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propCountry.TryReadProperty(ref reader, options, PropCountry, null)) + { + continue; + } + + if (propDecomposition.TryReadProperty(ref reader, options, PropDecomposition, null)) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propHiraganaQuaternaryMode.TryReadProperty(ref reader, options, PropHiraganaQuaternaryMode, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null)) + { + continue; + } + + if (propLanguage.TryReadProperty(ref reader, options, PropLanguage, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNorms.TryReadProperty(ref reader, options, PropNorms, null)) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propNumeric.TryReadProperty(ref reader, options, PropNumeric, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propRules.TryReadProperty(ref reader, options, PropRules, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propStrength.TryReadProperty(ref reader, options, PropStrength, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVariableTop.TryReadProperty(ref reader, options, PropVariableTop, null)) + { + continue; + } + + if (propVariant.TryReadProperty(ref reader, options, PropVariant, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCaseFirst, value.CaseFirst, null, null); + writer.WriteProperty(options, PropCaseLevel, value.CaseLevel, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropCountry, value.Country, null, null); + writer.WriteProperty(options, PropDecomposition, value.Decomposition, null, null); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropHiraganaQuaternaryMode, value.HiraganaQuaternaryMode, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null); + writer.WriteProperty(options, PropLanguage, value.Language, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNorms, value.Norms, null, null); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropNumeric, value.Numeric, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropRules, value.Rules, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropStrength, value.Strength, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropVariableTop, value.VariableTop, null, null); + writer.WriteProperty(options, PropVariant, value.Variant, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IcuCollationPropertyConverter))] public sealed partial class IcuCollationProperty : IProperty { - [JsonInclude, JsonPropertyName("alternate")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? Alternate { get; set; } - [JsonInclude, JsonPropertyName("case_first")] public Elastic.Clients.Elasticsearch.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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("country")] public string? Country { get; set; } - [JsonInclude, JsonPropertyName("decomposition")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? Decomposition { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +323,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.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("language")] public string? Language { get; set; } /// @@ -70,9 +332,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 +340,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.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.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/_Generated/Types/Mapping/IntegerNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs index 8d2512bed63..4c15e4c8fee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 IntegerNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class IntegerNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class IntegerNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "integer"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs index 47b66fc7aaf..cb47b9b40c3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs @@ -27,24 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +190,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.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/_Generated/Types/Mapping/IpProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs index 8a4ebec39cb..a57024d2000 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs @@ -27,24 +27,202 @@ namespace Elastic.Clients.Elasticsearch.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 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 IpProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +230,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -70,10 +242,8 @@ public sealed partial class IpProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "ip"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs index d714a86ad87..a9072bdc8c2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs @@ -27,24 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +190,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.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/_Generated/Types/Mapping/JoinProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/JoinProperty.g.cs index 6585e14e662..b1775cd28b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/JoinProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/JoinProperty.g.cs @@ -27,15 +27,118 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class JoinPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + 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 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 PropRelations = System.Text.Json.JsonEncodedText.Encode("relations"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override JoinProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue>>?> propRelations = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryReadProperty(ref reader, options, PropEagerGlobalOrdinals, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propRelations.TryReadProperty(ref reader, options, PropRelations, static IDictionary>>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new JoinProperty + { + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Relations = propRelations.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, JoinProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropRelations, value.Relations, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary>>? v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(JoinPropertyConverter))] public sealed partial class JoinProperty : IProperty { - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -43,14 +146,10 @@ public sealed partial class JoinProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("relations")] public IDictionary>>? Relations { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "join"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs index 8b3f61ce264..fc59fafa8fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs @@ -27,26 +27,253 @@ namespace Elastic.Clients.Elasticsearch.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 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 KeywordProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNormalizer = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propSplitQueriesOnWhitespace = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryReadProperty(ref reader, options, PropEagerGlobalOrdinals, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNormalizer.TryReadProperty(ref reader, options, PropNormalizer, null)) + { + continue; + } + + if (propNorms.TryReadProperty(ref reader, options, PropNorms, null)) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (propSplitQueriesOnWhitespace.TryReadProperty(ref reader, options, PropSplitQueriesOnWhitespace, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNormalizer, value.Normalizer, null, null); + writer.WriteProperty(options, PropNorms, value.Norms, null, null); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteProperty(options, PropSplitQueriesOnWhitespace, value.SplitQueriesOnWhitespace, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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.Mapping.IndexOptions? IndexOptions { get; set; } /// @@ -54,25 +281,15 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.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; } /// @@ -80,10 +297,8 @@ public sealed partial class KeywordProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "keyword"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs index e2454a28973..5e5c0ba4f42 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 LongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class LongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class LongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "long"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs index 301a1c2d56a..64563e9e9ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs @@ -27,24 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +190,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.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/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs index 4f7566ec1b8..d2368bcf4d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs @@ -27,6 +27,72 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propFields = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + /// /// /// A variant of text that trades scoring and efficiency of positional queries for space efficiency. This field @@ -36,6 +102,7 @@ namespace Elastic.Clients.Elasticsearch.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 +111,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.Fields? CopyTo { get; set; } /// @@ -54,7 +119,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.Mapping.Properties? Fields { get; set; } /// @@ -62,10 +126,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/_Generated/Types/Mapping/Murmur3HashProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs index 13bf5f0c702..c2ddff2ff16 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs @@ -27,18 +27,129 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(Murmur3HashPropertyConverter))] public sealed partial class Murmur3HashProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +157,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.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/_Generated/Types/Mapping/NestedProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs index 959c90ccf45..20b4d062634 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs @@ -27,22 +27,151 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIncludeInParent = default; + LocalJsonValue propIncludeInRoot = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIncludeInParent.TryReadProperty(ref reader, options, PropIncludeInParent, null)) + { + continue; + } + + if (propIncludeInRoot.TryReadProperty(ref reader, options, PropIncludeInRoot, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIncludeInParent, value.IncludeInParent, null, null); + writer.WriteProperty(options, PropIncludeInRoot, value.IncludeInRoot, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NestedPropertyConverter))] public sealed partial class NestedProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +179,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.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/_Generated/Types/Mapping/ObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs index 72b364f5dea..93be43d7d52 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs @@ -27,18 +27,139 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propSubobjects = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propSubobjects.TryReadProperty(ref reader, options, PropSubobjects, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropSubobjects, value.Subobjects, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ObjectPropertyConverter))] public sealed partial class ObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +167,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.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/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs index db4a8355410..f3ea3839903 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs @@ -27,18 +27,149 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPriority = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEnabled.TryReadProperty(ref reader, options, PropEnabled, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEnabled, value.Enabled, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PassthroughObjectPropertyConverter))] public sealed partial class PassthroughObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,18 +177,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.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/_Generated/Types/Mapping/PointProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs index b02111781c2..70a6693d391 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs @@ -27,22 +27,161 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIgnoreZValue.TryReadProperty(ref reader, options, PropIgnoreZValue, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PointPropertyConverter))] public sealed partial class PointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +189,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.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/_Generated/Types/Mapping/Properties.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs index b3b3c49457d..e0855cc9e24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs @@ -318,289 +318,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, null)) + { + 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, null), + "binary" => reader.ReadValue(options, null), + "boolean" => reader.ReadValue(options, null), + "byte" => reader.ReadValue(options, null), + "completion" => reader.ReadValue(options, null), + "constant_keyword" => reader.ReadValue(options, null), + "date_nanos" => reader.ReadValue(options, null), + "date" => reader.ReadValue(options, null), + "date_range" => reader.ReadValue(options, null), + "dense_vector" => reader.ReadValue(options, null), + "double" => reader.ReadValue(options, null), + "double_range" => reader.ReadValue(options, null), + "{dynamic_type}" => reader.ReadValue(options, null), + "alias" => reader.ReadValue(options, null), + "flattened" => reader.ReadValue(options, null), + "float" => reader.ReadValue(options, null), + "float_range" => reader.ReadValue(options, null), + "geo_point" => reader.ReadValue(options, null), + "geo_shape" => reader.ReadValue(options, null), + "half_float" => reader.ReadValue(options, null), + "histogram" => reader.ReadValue(options, null), + "icu_collation_keyword" => reader.ReadValue(options, null), + "integer" => reader.ReadValue(options, null), + "integer_range" => reader.ReadValue(options, null), + "ip" => reader.ReadValue(options, null), + "ip_range" => reader.ReadValue(options, null), + "join" => reader.ReadValue(options, null), + "keyword" => reader.ReadValue(options, null), + "long" => reader.ReadValue(options, null), + "long_range" => reader.ReadValue(options, null), + "match_only_text" => reader.ReadValue(options, null), + "murmur3" => reader.ReadValue(options, null), + "nested" => reader.ReadValue(options, null), + "object" => reader.ReadValue(options, null), + "passthrough" => reader.ReadValue(options, null), + "percolator" => reader.ReadValue(options, null), + "point" => reader.ReadValue(options, null), + "rank_feature" => reader.ReadValue(options, null), + "rank_features" => reader.ReadValue(options, null), + "scaled_float" => reader.ReadValue(options, null), + "search_as_you_type" => reader.ReadValue(options, null), + "semantic_text" => reader.ReadValue(options, null), + "shape" => reader.ReadValue(options, null), + "short" => reader.ReadValue(options, null), + "sparse_vector" => reader.ReadValue(options, null), + "text" => reader.ReadValue(options, null), + "token_count" => reader.ReadValue(options, null), + "unsigned_long" => reader.ReadValue(options, null), + "version" => reader.ReadValue(options, null), + "wildcard" => reader.ReadValue(options, null), + _ => 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.Mapping.AggregateMetricDoubleProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.AggregateMetricDoubleProperty)value, null); + break; case "binary": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.BinaryProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.BinaryProperty)value, null); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.BooleanProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.BooleanProperty)value, null); + break; case "byte": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ByteNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ByteNumberProperty)value, null); + break; case "completion": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.CompletionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.CompletionProperty)value, null); + break; case "constant_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ConstantKeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ConstantKeywordProperty)value, null); + break; case "date_nanos": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateNanosProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateNanosProperty)value, null); + break; case "date": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateProperty)value, null); + break; case "date_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateRangeProperty)value, null); + break; case "dense_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DenseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DenseVectorProperty)value, null); + break; case "double": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DoubleNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DoubleNumberProperty)value, null); + break; case "double_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DoubleRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DoubleRangeProperty)value, null); + break; case "{dynamic_type}": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DynamicProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DynamicProperty)value, null); + break; case "alias": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FieldAliasProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FieldAliasProperty)value, null); + break; case "flattened": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FlattenedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FlattenedProperty)value, null); + break; case "float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FloatNumberProperty)value, null); + break; case "float_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FloatRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FloatRangeProperty)value, null); + break; case "geo_point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.GeoPointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.GeoPointProperty)value, null); + break; case "geo_shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.GeoShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.GeoShapeProperty)value, null); + break; case "half_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.HalfFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.HalfFloatNumberProperty)value, null); + break; case "histogram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.HistogramProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.HistogramProperty)value, null); + break; case "icu_collation_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IcuCollationProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IcuCollationProperty)value, null); + break; case "integer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IntegerNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IntegerNumberProperty)value, null); + break; case "integer_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IntegerRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IntegerRangeProperty)value, null); + break; case "ip": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IpProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IpProperty)value, null); + break; case "ip_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IpRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IpRangeProperty)value, null); + break; case "join": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.JoinProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.JoinProperty)value, null); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.KeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.KeywordProperty)value, null); + break; case "long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.LongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.LongNumberProperty)value, null); + break; case "long_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.LongRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.LongRangeProperty)value, null); + break; case "match_only_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.MatchOnlyTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.MatchOnlyTextProperty)value, null); + break; case "murmur3": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.Murmur3HashProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.Murmur3HashProperty)value, null); + break; case "nested": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.NestedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.NestedProperty)value, null); + break; case "object": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ObjectProperty)value, null); + break; case "passthrough": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PassthroughObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PassthroughObjectProperty)value, null); + break; case "percolator": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PercolatorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PercolatorProperty)value, null); + break; case "point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PointProperty)value, null); + break; case "rank_feature": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.RankFeatureProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.RankFeatureProperty)value, null); + break; case "rank_features": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.RankFeaturesProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.RankFeaturesProperty)value, null); + break; case "scaled_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ScaledFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ScaledFloatNumberProperty)value, null); + break; case "search_as_you_type": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SearchAsYouTypeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SearchAsYouTypeProperty)value, null); + break; case "semantic_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty)value, null); + break; case "shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ShapeProperty)value, null); + break; case "short": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ShortNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ShortNumberProperty)value, null); + break; case "sparse_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SparseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SparseVectorProperty)value, null); + break; case "text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.TextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.TextProperty)value, null); + break; case "token_count": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.TokenCountProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.TokenCountProperty)value, null); + break; case "unsigned_long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.UnsignedLongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.UnsignedLongNumberProperty)value, null); + break; case "version": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.VersionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.VersionProperty)value, null); + break; case "wildcard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.WildcardProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.WildcardProperty)value, null); + 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/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs index e541c98952f..708339d0caf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs @@ -27,11 +27,64 @@ namespace Elastic.Clients.Elasticsearch.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) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options, null); + return new RuntimeFieldFetchFields { Field = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + 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, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuntimeFieldFetchFieldsConverter))] public sealed partial class RuntimeFieldFetchFields { - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs index af85a307d39..4002245d912 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs @@ -27,26 +27,233 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 ScaledFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScalingFactor = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScalingFactor.TryReadProperty(ref reader, options, PropScalingFactor, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScalingFactor, value.ScalingFactor, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,19 +261,12 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("scaling_factor")] public double? ScalingFactor { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -74,7 +274,6 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -82,10 +281,8 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "scaled_float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs index 01869286d25..6d607ab023f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs @@ -27,24 +27,212 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propMaxShingleSize = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null)) + { + continue; + } + + if (propMaxShingleSize.TryReadProperty(ref reader, options, PropMaxShingleSize, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNorms.TryReadProperty(ref reader, options, PropNorms, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propSearchAnalyzer.TryReadProperty(ref reader, options, PropSearchAnalyzer, null)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryReadProperty(ref reader, options, PropSearchQuoteAnalyzer, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTermVector.TryReadProperty(ref reader, options, PropTermVector, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null); + writer.WriteProperty(options, PropMaxShingleSize, value.MaxShingleSize, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNorms, value.Norms, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer, null, null); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTermVector, value.TermVector, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("max_shingle_size")] public int? MaxShingleSize { get; set; } /// @@ -52,24 +240,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.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.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "search_as_you_type"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs index 746ae77f100..f747f290f5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs @@ -27,6 +27,162 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propOrientation = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIgnoreZValue.TryReadProperty(ref reader, options, PropIgnoreZValue, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propOrientation.TryReadProperty(ref reader, options, PropOrientation, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropOrientation, value.Orientation, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + /// /// /// The shape data type facilitates the indexing of and searching with arbitrary x, y cartesian shapes such as @@ -34,24 +190,16 @@ namespace Elastic.Clients.Elasticsearch.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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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 +207,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.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.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/_Generated/Types/Mapping/ShortNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs index 828c1519a6d..98397846207 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 ShortNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class ShortNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class ShortNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "short"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs index 507e09126cc..15328fe91fc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs @@ -27,34 +27,277 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFielddataFrequencyFilter = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propIndexPhrases = default; + LocalJsonValue propIndexPrefixes = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryReadProperty(ref reader, options, PropEagerGlobalOrdinals, null)) + { + continue; + } + + if (propFielddata.TryReadProperty(ref reader, options, PropFielddata, null)) + { + continue; + } + + if (propFielddataFrequencyFilter.TryReadProperty(ref reader, options, PropFielddataFrequencyFilter, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null)) + { + continue; + } + + if (propIndexPhrases.TryReadProperty(ref reader, options, PropIndexPhrases, null)) + { + continue; + } + + if (propIndexPrefixes.TryReadProperty(ref reader, options, PropIndexPrefixes, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNorms.TryReadProperty(ref reader, options, PropNorms, null)) + { + continue; + } + + if (propPositionIncrementGap.TryReadProperty(ref reader, options, PropPositionIncrementGap, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propSearchAnalyzer.TryReadProperty(ref reader, options, PropSearchAnalyzer, null)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryReadProperty(ref reader, options, PropSearchQuoteAnalyzer, null)) + { + continue; + } + + if (propSimilarity.TryReadProperty(ref reader, options, PropSimilarity, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTermVector.TryReadProperty(ref reader, options, PropTermVector, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals, null, null); + writer.WriteProperty(options, PropFielddata, value.Fielddata, null, null); + writer.WriteProperty(options, PropFielddataFrequencyFilter, value.FielddataFrequencyFilter, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases, null, null); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNorms, value.Norms, null, null); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer, null, null); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer, null, null); + writer.WriteProperty(options, PropSimilarity, value.Similarity, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTermVector, value.TermVector, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.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.IndexManagement.FielddataFrequencyFilter? FielddataFrequencyFilter { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } /// @@ -62,26 +305,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.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.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "text"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs index 6a9e2302b3e..7a3809a7f19 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs @@ -27,26 +27,183 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnablePositionIncrements = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propEnablePositionIncrements.TryReadProperty(ref reader, options, PropEnablePositionIncrements, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropEnablePositionIncrements, value.EnablePositionIncrements, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enable_position_increments")] public bool? EnablePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,16 +211,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.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/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs index 0d7d4bebd18..a4221defacd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs @@ -27,26 +27,223 @@ namespace Elastic.Clients.Elasticsearch.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 PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + 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 UnsignedLongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propCoerce.TryReadProperty(ref reader, options, PropCoerce, null)) + { + continue; + } + + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propIgnoreMalformed.TryReadProperty(ref reader, options, PropIgnoreMalformed, null)) + { + continue; + } + + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propOnScriptError.TryReadProperty(ref reader, options, PropOnScriptError, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (propTimeSeriesDimension.TryReadProperty(ref reader, options, PropTimeSeriesDimension, null)) + { + continue; + } + + if (propTimeSeriesMetric.TryReadProperty(ref reader, options, PropTimeSeriesMetric, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.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, null, null); + writer.WriteProperty(options, PropCoerce, value.Coerce, null, null); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed, null, null); + writer.WriteProperty(options, PropIndex, value.Index, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension, null, null); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.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,17 +251,11 @@ 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.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +263,6 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +270,8 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "unsigned_long"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs index aeab1142b5e..82ae8a0324d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs @@ -27,18 +27,129 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VersionPropertyConverter))] public sealed partial class VersionProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +157,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.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/_Generated/Types/Mapping/WildcardProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs index a35b3b65721..9b7f341ad53 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs @@ -27,18 +27,139 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryReadProperty(ref reader, options, PropCopyTo, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propDocValues.TryReadProperty(ref reader, options, PropDocValues, null)) + { + continue; + } + + if (propDynamic.TryReadProperty(ref reader, options, PropDynamic, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, null)) + { + continue; + } + + if (propIgnoreAbove.TryReadProperty(ref reader, options, PropIgnoreAbove, null)) + { + continue; + } + + if (propMeta.TryReadProperty(ref reader, options, PropMeta, static IDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propNullValue.TryReadProperty(ref reader, options, PropNullValue, null)) + { + continue; + } + + if (propProperties.TryReadProperty(ref reader, options, PropProperties, null)) + { + continue; + } + + if (propStore.TryReadProperty(ref reader, options, PropStore, null)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropDocValues, value.DocValues, null, null); + writer.WriteProperty(options, PropDynamic, value.Dynamic, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, null); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove, null, null); + writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropNullValue, value.NullValue, null, null); + writer.WriteProperty(options, PropProperties, value.Properties, null, null); + writer.WriteProperty(options, PropStore, value.Store, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(WildcardPropertyConverter))] public sealed partial class WildcardProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +167,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.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/_Generated/Types/Nodes/NodeInfoDiscover.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs index 82482a861f6..91ed3de69a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs @@ -27,51 +27,69 @@ namespace Elastic.Clients.Elasticsearch.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 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; + LocalJsonValue?> propSeedHosts = default; + LocalJsonValue?> propSeedProviders = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propSeedHosts.TryReadProperty(ref reader, options, PropSeedHosts, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) { - 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.TryReadProperty(ref reader, options, PropSeedProviders, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropSeedProviders, value.SeedProviders, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropType, value.Type, null, null); + 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/_Generated/Types/Nodes/NodeInfoPath.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs index d80db597c5b..bcbbb892112 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs @@ -27,15 +27,79 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propData = default; + LocalJsonValue propHome = default; + LocalJsonValue propLogs = default; + LocalJsonValue?> propRepo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryReadProperty(ref reader, options, PropData, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propHome.TryReadProperty(ref reader, options, PropHome, null)) + { + continue; + } + + if (propLogs.TryReadProperty(ref reader, options, PropLogs, null)) + { + continue; + } + + if (propRepo.TryReadProperty(ref reader, options, PropRepo, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropHome, value.Home, null, null); + writer.WriteProperty(options, PropLogs, value.Logs, null, null); + writer.WriteProperty(options, PropRepo, value.Repo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + 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/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs index 59254699ab8..5d5cf1e1a32 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs @@ -27,8 +27,52 @@ namespace Elastic.Clients.Elasticsearch.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, null); + return new NodeInfoSettingsHttpType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryReadProperty(ref reader, options, PropDefault, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs index 34db00f7452..d459949cd6f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs @@ -27,9 +27,46 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propHost = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHost.TryReadProperty(ref reader, options, PropHost, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + 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/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs index 4ffc3899a83..3cbf7d12e75 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs @@ -27,8 +27,52 @@ namespace Elastic.Clients.Elasticsearch.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, null); + return new NodeInfoSettingsTransportType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryReadProperty(ref reader, options, PropDefault, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + 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/_Generated/Types/Nodes/NodeJvmInfo.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs index 47707519655..7dd8a14520d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs @@ -27,109 +27,152 @@ namespace Elastic.Clients.Elasticsearch.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.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); + LocalJsonValue> propGcCollectors = default; + LocalJsonValue> propInputArguments = default; + LocalJsonValue propMem = default; + LocalJsonValue> propMemoryPools = default; + LocalJsonValue propPid = default; + LocalJsonValue propStartTimeInMillis = default; + LocalJsonValue propUsingBundledJdk = default; + LocalJsonValue propUsingCompressedOrdinaryObjectPointers = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVmName = default; + LocalJsonValue propVmVendor = default; + LocalJsonValue propVmVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propGcCollectors.TryReadProperty(ref reader, options, PropGcCollectors, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) { - 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.TryReadProperty(ref reader, options, PropInputArguments, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propMem.TryReadProperty(ref reader, options, PropMem, null)) + { + continue; + } + + if (propMemoryPools.TryReadProperty(ref reader, options, PropMemoryPools, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (propPid.TryReadProperty(ref reader, options, PropPid, null)) + { + continue; + } + + if (propStartTimeInMillis.TryReadProperty(ref reader, options, PropStartTimeInMillis, null)) + { + continue; + } + + if (propUsingBundledJdk.TryReadProperty(ref reader, options, PropUsingBundledJdk, null) || propUsingBundledJdk.TryReadProperty(ref reader, options, PropUsingBundledJdk1, null)) + { + continue; + } + + if (propUsingCompressedOrdinaryObjectPointers.TryReadProperty(ref reader, options, PropUsingCompressedOrdinaryObjectPointers, null)) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (propVmName.TryReadProperty(ref reader, options, PropVmName, null)) + { + continue; + } + + if (propVmVendor.TryReadProperty(ref reader, options, PropVmVendor, null)) + { + continue; + } + + if (propVmVersion.TryReadProperty(ref reader, options, PropVmVersion, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropInputArguments, value.InputArguments, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMem, value.Mem, null, null); + writer.WriteProperty(options, PropMemoryPools, value.MemoryPools, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPid, value.Pid, null, null); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis, null, null); + writer.WriteProperty(options, PropUsingBundledJdk, value.UsingBundledJdk, null, null); + writer.WriteProperty(options, PropUsingCompressedOrdinaryObjectPointers, value.UsingCompressedOrdinaryObjectPointers, null, null); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteProperty(options, PropVmName, value.VmName, null, null); + writer.WriteProperty(options, PropVmVendor, value.VmVendor, null, null); + writer.WriteProperty(options, PropVmVersion, value.VmVersion, null, null); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeReloadResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeReloadResult.g.cs index e0ad61a6cd6..7347d388386 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeReloadResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeReloadResult.g.cs @@ -30,13 +30,52 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +[JsonConverter(typeof(NodeReloadResultConverter))] public sealed partial class NodeReloadResult : Union { - public NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.Stats Stats) : base(Stats) + public NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.Stats stats) : base(stats) { } - public NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.NodeReloadError Error) : base(Error) + public NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.NodeReloadError error) : base(error) { } + + public static implicit operator NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.Stats stats) => new NodeReloadResult(stats); + public static implicit operator NodeReloadResult(Elastic.Clients.Elasticsearch.Nodes.NodeReloadError error) => new NodeReloadResult(error); +} + +internal sealed partial class NodeReloadResultConverter : System.Text.Json.Serialization.JsonConverter +{ + public override NodeReloadResult Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByPropertyOfT2(ref r, o, "name"); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new NodeReloadResult(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new NodeReloadResult(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(NodeReloadResult)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeReloadResult value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs index 069731edd49..3fdf7e40a8a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs @@ -27,6 +27,255 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue?> propAdaptiveSelection = default; + LocalJsonValue?> propAttributes = default; + LocalJsonValue?> propBreakers = default; + LocalJsonValue propDiscovery = default; + LocalJsonValue propFs = default; + LocalJsonValue propHost = default; + LocalJsonValue propHttp = default; + LocalJsonValue propIndexingPressure = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIngest = default; + LocalJsonValue?> propIp = default; + LocalJsonValue propJvm = default; + LocalJsonValue propName = default; + LocalJsonValue propOs = default; + LocalJsonValue propProcess = default; + LocalJsonValue?> propRoles = default; + LocalJsonValue propScript = default; + LocalJsonValue>>?> propScriptCache = default; + LocalJsonValue?> propThreadPool = default; + LocalJsonValue propTimestamp = default; + LocalJsonValue propTransport = default; + LocalJsonValue propTransportAddress = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAdaptiveSelection.TryReadProperty(ref reader, options, PropAdaptiveSelection, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propAttributes.TryReadProperty(ref reader, options, PropAttributes, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propBreakers.TryReadProperty(ref reader, options, PropBreakers, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propDiscovery.TryReadProperty(ref reader, options, PropDiscovery, null)) + { + continue; + } + + if (propFs.TryReadProperty(ref reader, options, PropFs, null)) + { + continue; + } + + if (propHost.TryReadProperty(ref reader, options, PropHost, null)) + { + continue; + } + + if (propHttp.TryReadProperty(ref reader, options, PropHttp, null)) + { + continue; + } + + if (propIndexingPressure.TryReadProperty(ref reader, options, PropIndexingPressure, null)) + { + continue; + } + + if (propIndices.TryReadProperty(ref reader, options, PropIndices, null)) + { + continue; + } + + if (propIngest.TryReadProperty(ref reader, options, PropIngest, null)) + { + continue; + } + + if (propIp.TryReadProperty(ref reader, options, PropIp, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propJvm.TryReadProperty(ref reader, options, PropJvm, null)) + { + continue; + } + + if (propName.TryReadProperty(ref reader, options, PropName, null)) + { + continue; + } + + if (propOs.TryReadProperty(ref reader, options, PropOs, null)) + { + continue; + } + + if (propProcess.TryReadProperty(ref reader, options, PropProcess, null)) + { + continue; + } + + if (propRoles.TryReadProperty(ref reader, options, PropRoles, static IReadOnlyCollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propScript.TryReadProperty(ref reader, options, PropScript, null)) + { + continue; + } + + if (propScriptCache.TryReadProperty(ref reader, options, PropScriptCache, static IReadOnlyDictionary>>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue>>(o, null, static Union> (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadUnionValue>(o, static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray), null, static IReadOnlyCollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)!))) + { + continue; + } + + if (propThreadPool.TryReadProperty(ref reader, options, PropThreadPool, static IReadOnlyDictionary? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue(o, null, null))) + { + continue; + } + + if (propTimestamp.TryReadProperty(ref reader, options, PropTimestamp, null)) + { + continue; + } + + if (propTransport.TryReadProperty(ref reader, options, PropTransport, null)) + { + continue; + } + + if (propTransportAddress.TryReadProperty(ref reader, options, PropTransportAddress, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropAttributes, value.Attributes, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropBreakers, value.Breakers, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropDiscovery, value.Discovery, null, null); + writer.WriteProperty(options, PropFs, value.Fs, null, null); + writer.WriteProperty(options, PropHost, value.Host, null, null); + writer.WriteProperty(options, PropHttp, value.Http, null, null); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure, null, null); + writer.WriteProperty(options, PropIndices, value.Indices, null, null); + writer.WriteProperty(options, PropIngest, value.Ingest, null, null); + writer.WriteProperty(options, PropIp, value.Ip, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropJvm, value.Jvm, null, null); + writer.WriteProperty(options, PropName, value.Name, null, null); + writer.WriteProperty(options, PropOs, value.Os, null, null); + writer.WriteProperty(options, PropProcess, value.Process, null, null); + writer.WriteProperty(options, PropRoles, value.Roles, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropScript, value.Script, null, null); + writer.WriteProperty(options, PropScriptCache, value.ScriptCache, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary>>? v) => w.WriteDictionaryValue>>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Union> v) => w.WriteUnionValue>(o, v, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyCollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)))); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, IReadOnlyDictionary? v) => w.WriteDictionaryValue(o, v, null, null)); + writer.WriteProperty(options, PropTimestamp, value.Timestamp, null, null); + writer.WriteProperty(options, PropTransport, value.Transport, null, null); + writer.WriteProperty(options, PropTransportAddress, value.TransportAddress, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StatsConverter))] public sealed partial class Stats { /// @@ -34,7 +283,6 @@ public sealed partial class Stats /// Statistics about adaptive replica selection. /// /// - [JsonInclude, JsonPropertyName("adaptive_selection")] public IReadOnlyDictionary? AdaptiveSelection { get; init; } /// @@ -42,8 +290,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 +297,6 @@ public sealed partial class Stats /// Statistics about the field data circuit breaker. /// /// - [JsonInclude, JsonPropertyName("breakers")] public IReadOnlyDictionary? Breakers { get; init; } /// @@ -59,7 +304,6 @@ public sealed partial class Stats /// Contains node discovery statistics for the node. /// /// - [JsonInclude, JsonPropertyName("discovery")] public Elastic.Clients.Elasticsearch.Nodes.Discovery? Discovery { get; init; } /// @@ -67,7 +311,6 @@ public sealed partial class Stats /// File system information, data path, free disk space, read/write stats. /// /// - [JsonInclude, JsonPropertyName("fs")] public Elastic.Clients.Elasticsearch.Nodes.FileSystem? Fs { get; init; } /// @@ -75,7 +318,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 +325,6 @@ public sealed partial class Stats /// HTTP connection information. /// /// - [JsonInclude, JsonPropertyName("http")] public Elastic.Clients.Elasticsearch.Nodes.Http? Http { get; init; } /// @@ -91,7 +332,6 @@ public sealed partial class Stats /// Contains indexing pressure statistics for the node. /// /// - [JsonInclude, JsonPropertyName("indexing_pressure")] public Elastic.Clients.Elasticsearch.Nodes.IndexingPressure? IndexingPressure { get; init; } /// @@ -99,7 +339,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.IndexManagement.ShardStats? Indices { get; init; } /// @@ -107,7 +346,6 @@ public sealed partial class Stats /// Statistics about ingest preprocessing. /// /// - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Nodes.Ingest? Ingest { get; init; } /// @@ -115,8 +353,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 +360,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.Nodes.Jvm? Jvm { get; init; } /// @@ -133,7 +368,6 @@ public sealed partial class Stats /// Based on the node name setting. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; init; } /// @@ -141,7 +375,6 @@ public sealed partial class Stats /// Operating system stats, load average, mem, swap. /// /// - [JsonInclude, JsonPropertyName("os")] public Elastic.Clients.Elasticsearch.Nodes.OperatingSystem? Os { get; init; } /// @@ -149,7 +382,6 @@ public sealed partial class Stats /// Process statistics, memory consumption, cpu usage, open file descriptors. /// /// - [JsonInclude, JsonPropertyName("process")] public Elastic.Clients.Elasticsearch.Nodes.Process? Process { get; init; } /// @@ -157,7 +389,6 @@ public sealed partial class Stats /// Roles assigned to the node. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection? Roles { get; init; } /// @@ -165,9 +396,7 @@ public sealed partial class Stats /// Contains script statistics for the node. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Nodes.Scripting? Script { get; init; } - [JsonInclude, JsonPropertyName("script_cache")] public IReadOnlyDictionary>>? ScriptCache { get; init; } /// @@ -175,9 +404,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 +412,6 @@ public sealed partial class Stats /// Transport statistics about sent and received bytes in cluster communication. /// /// - [JsonInclude, JsonPropertyName("transport")] public Elastic.Clients.Elasticsearch.Nodes.Transport? Transport { get; init; } /// @@ -193,6 +419,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/_Generated/Types/QueryDsl/BoolQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs index bbf7f54b574..b1a102b95e7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs @@ -27,6 +27,105 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propBoost = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue?> propMust = default; + LocalJsonValue?> propMustNot = default; + LocalJsonValue propQueryName = default; + LocalJsonValue?> propShould = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMinimumShouldMatch.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + continue; + } + + if (propMust.TryReadProperty(ref reader, options, PropMust, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMustNot.TryReadProperty(ref reader, options, PropMustNot, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propShould.TryReadProperty(ref reader, options, PropShould, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropFilter, value.Filter, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropMust, value.Must, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMustNot, value.MustNot, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropShould, value.Should, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BoolQueryConverter))] public sealed partial class BoolQuery { /// @@ -37,7 +136,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 +144,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.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -55,7 +151,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.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -63,8 +158,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.QueryDsl.Query))] public ICollection? Must { get; set; } /// @@ -73,10 +166,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.QueryDsl.Query))] public ICollection? MustNot { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -84,8 +174,6 @@ public sealed partial class BoolQuery /// The clause (query) should appear in the matching document. /// /// - [JsonInclude, JsonPropertyName("should")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Should { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(BoolQuery boolQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.Bool(boolQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs index 387ff96f3a0..71bcb5fff56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs @@ -54,7 +54,6 @@ public sealed partial class CombinedFieldsQuery /// /// [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs index 2694b98502b..80f0f3ed27b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs @@ -27,60 +27,49 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryReadProperty(ref reader, options, PropMultiValueMode, null)) { - 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, null, null); } - 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, null, null); + writer.WriteProperty(options, value.Field, value.Placement, null, null); writer.WriteEndObject(); } } [JsonConverter(typeof(DateDecayFunctionConverter))] -public sealed partial class DateDecayFunction +public sealed partial class DateDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +80,8 @@ public sealed partial class DateDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "datedecayfunction"; } public sealed partial class DateDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs index bfa49e3ec4b..1606b09c462 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.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.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/_Generated/Types/QueryDsl/DateRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs index 537b0a37d46..c806af0d651 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs @@ -27,151 +27,138 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new DateRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropFormat, null)) + { + 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.TryReadProperty(ref reader, options, PropGt, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryReadProperty(ref reader, options, PropGte, null)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryReadProperty(ref reader, options, PropLt, null)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryReadProperty(ref reader, options, PropLte, null)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryReadProperty(ref reader, options, PropRelation, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryReadProperty(ref reader, options, PropTimeZone, null)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropGt, value.Gt, null, null); + writer.WriteProperty(options, PropGte, value.Gte, null, null); + writer.WriteProperty(options, PropLt, value.Lt, null, null); + writer.WriteProperty(options, PropLte, value.Lte, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRelation, value.Relation, null, null); + writer.WriteProperty(options, PropTimeZone, value.TimeZone, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(DateRangeQueryConverter))] -public sealed partial class DateRangeQuery +public sealed partial class DateRangeQuery : IRangeQuery { public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -180,6 +167,10 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal DateRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +231,8 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "daterangequery"; } public sealed partial class DateRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs new file mode 100644 index 00000000000..9fe01485578 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs @@ -0,0 +1,63 @@ +// 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.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.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, null); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction v: + writer.WriteValue(options, v, null); + 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/_Generated/Types/QueryDsl/DecayPlacement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs index cd6e15ce644..af24bf985d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs @@ -27,6 +27,92 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propDecay = default; + LocalJsonValue propOffset = default; + LocalJsonValue propOrigin = default; + LocalJsonValue propScale = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDecay.TryReadProperty(ref reader, options, PropDecay, null)) + { + continue; + } + + if (propOffset.TryReadProperty(ref reader, options, PropOffset, null)) + { + continue; + } + + if (propOrigin.TryReadProperty(ref reader, options, PropOrigin, null)) + { + continue; + } + + if (propScale.TryReadProperty(ref reader, options, PropScale, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropOffset, value.Offset, null, null); + writer.WriteProperty(options, PropOrigin, value.Origin, null, null); + writer.WriteProperty(options, PropScale, value.Scale, null, null); + 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 +120,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 +127,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 +134,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 +141,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/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs new file mode 100644 index 00000000000..4438ea4dd91 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs @@ -0,0 +1,60 @@ +// 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.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.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, null); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDistanceFeatureQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery v: + writer.WriteValue(options, v, null); + 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/_Generated/Types/QueryDsl/FieldAndFormat.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs index 16db583ecbe..d4115b50d5c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs @@ -27,11 +27,76 @@ namespace Elastic.Clients.Elasticsearch.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) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options, null); + return new FieldAndFormat { Field = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIncludeUnmapped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryReadProperty(ref reader, options, PropField, null)) + { + continue; + } + + if (propFormat.TryReadProperty(ref reader, options, PropFormat, null)) + { + continue; + } + + if (propIncludeUnmapped.TryReadProperty(ref reader, options, PropIncludeUnmapped, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + 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, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropIncludeUnmapped, value.IncludeUnmapped, null, null); + 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.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/_Generated/Types/QueryDsl/FunctionScore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs index 15eea6a6ae2..67b6bf16e2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs @@ -39,22 +39,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.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => new FunctionScore("field_value_factor", fieldValueFactorScoreFunction); + public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); + public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); @@ -80,137 +87,134 @@ 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.QueryDsl.Query? filterValue = default; - double? weightValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFilter = default; + LocalJsonValue 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) + if (propFilter.TryReadProperty(ref reader, options, PropFilter, null)) { - 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 == "filter") + if (propWeight.TryReadProperty(ref reader, options, PropWeight, null)) { - filterValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "weight") + if (reader.ValueTextEquals(VariantExp)) { - weightValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantExp.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "exp") + if (reader.ValueTextEquals(VariantFieldValueFactor)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFieldValueFactor.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "field_value_factor") + if (reader.ValueTextEquals(VariantGauss)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGauss.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "gauss") + if (reader.ValueTextEquals(VariantLinear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinear.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "linear") + if (reader.ValueTextEquals(VariantRandomScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRandomScore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "random_score") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "script_score") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.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.QueryDsl.RandomScoreFunction)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreFunction)value.Variant, options); - break; - } + case "": + break; + case "exp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant, null, null); + break; + case "field_value_factor": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction?)value.Variant, null, null); + break; + case "gauss": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant, null, null); + break; + case "linear": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant, null, null); + break; + case "random_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RandomScoreFunction?)value.Variant, null, null); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreFunction?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FunctionScore)}'."); } + writer.WriteProperty(options, PropFilter, value.Filter, null, null); + writer.WriteProperty(options, PropWeight, value.Weight, null, null); writer.WriteEndObject(); } } @@ -261,16 +265,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); @@ -358,16 +365,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs index 0b27f35c415..1b031ce6320 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs @@ -27,6 +27,121 @@ namespace Elastic.Clients.Elasticsearch.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, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)); + return new FunctionScoreQuery { Functions = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propBoostMode = default; + LocalJsonValue?> propFunctions = default; + LocalJsonValue propMaxBoost = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propScoreMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propBoostMode.TryReadProperty(ref reader, options, PropBoostMode, null)) + { + continue; + } + + if (propFunctions.TryReadProperty(ref reader, options, PropFunctions, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null))) + { + continue; + } + + if (propMaxBoost.TryReadProperty(ref reader, options, PropMaxBoost, null)) + { + continue; + } + + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propScoreMode.TryReadProperty(ref reader, options, PropScoreMode, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoostMode, value.BoostMode, null, null); + writer.WriteProperty(options, PropFunctions, value.Functions, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMaxBoost, value.MaxBoost, null, null); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropScoreMode, value.ScoreMode, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FunctionScoreQueryConverter))] public sealed partial class FunctionScoreQuery { /// @@ -37,7 +152,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 +159,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.QueryDsl.FunctionBoostMode? BoostMode { get; set; } /// @@ -53,7 +166,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 +173,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 +180,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 +187,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.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -87,7 +195,6 @@ public sealed partial class FunctionScoreQuery /// Specifies how the computed scores are combined /// /// - [JsonInclude, JsonPropertyName("score_mode")] public Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreMode? ScoreMode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(FunctionScoreQuery functionScoreQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.FunctionScore(functionScoreQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs index 511e2e5009d..0e9a86229de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs @@ -27,128 +27,128 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new FuzzyQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propTranspositions = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropFuzziness, null)) + { + 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.TryReadProperty(ref reader, options, PropMaxExpansions, null)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propPrefixLength.TryReadProperty(ref reader, options, PropPrefixLength, null)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propRewrite.TryReadProperty(ref reader, options, PropRewrite, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTranspositions.TryReadProperty(ref reader, options, PropTranspositions, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness, null, null); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions, null, null); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRewrite, value.Rewrite, null, null); + writer.WriteProperty(options, PropTranspositions, value.Transpositions, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -164,6 +164,10 @@ public FuzzyQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs index 8833c66c219..6ae210c86d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs @@ -27,90 +27,73 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propBoundingBox = default; + LocalJsonValue propField = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) { - 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryReadProperty(ref reader, options, PropValidationMethod, null)) + { + 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, null, null); } - 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, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod, null, null); + writer.WriteProperty(options, value.Field, value.BoundingBox, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs index 446768423be..957c063b328 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs @@ -27,60 +27,49 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryReadProperty(ref reader, options, PropMultiValueMode, null)) { - 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, null, null); } - 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, null, null); + writer.WriteProperty(options, value.Field, value.Placement, null, null); writer.WriteEndObject(); } } [JsonConverter(typeof(GeoDecayFunctionConverter))] -public sealed partial class GeoDecayFunction +public sealed partial class GeoDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +80,8 @@ public sealed partial class GeoDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "geodecayfunction"; } public sealed partial class GeoDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs index 5c04cad4816..e93b625fb09 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs index 04dae04ae98..63113dac9f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs @@ -27,110 +27,93 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue propLocation = default; + LocalJsonValue propBoost = default; + LocalJsonValue propDistance = default; + LocalJsonValue propDistanceType = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropDistance, null)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Location, options); - } + if (propDistanceType.TryReadProperty(ref reader, options, PropDistanceType, null)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propIgnoreUnmapped.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) + { + 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryReadProperty(ref reader, options, PropValidationMethod, null)) + { + 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, null, null); } - 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, null, null); + writer.WriteProperty(options, PropDistance, value.Distance, null, null); + writer.WriteProperty(options, PropDistanceType, value.DistanceType, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod, null, null); + writer.WriteProperty(options, value.Field, value.Location, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs index ec6e5429145..9c0177edefd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs @@ -27,78 +27,63 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue propShape = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) { - 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + 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, null, null); } - 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, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, value.Field, value.Shape, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs index dc8261d52d0..2ccc3022cf4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs @@ -39,12 +39,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.QueryDsl.IntervalsAllOf intervalsAllOf) => new Intervals("all_of", intervalsAllOf); public static Intervals AnyOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new Intervals("any_of", intervalsAnyOf); @@ -66,107 +70,109 @@ 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) + if (reader.ValueTextEquals(VariantAllOf)) { - 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."); + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "all_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "wildcard") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf?)value.Variant, null, null); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf?)value.Variant, null, null); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy?)value.Variant, null, null); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch?)value.Variant, null, null); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix?)value.Variant, null, null); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard?)value.Variant, null, null); + 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/_Generated/Types/QueryDsl/IntervalsFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs index 09e338e1fe9..240d0d370ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs @@ -39,12 +39,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.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("after", intervalsContainer); public static IntervalsFilter Before(Elastic.Clients.Elasticsearch.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("before", intervalsContainer); @@ -69,137 +73,145 @@ 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) + if (reader.ValueTextEquals(VariantAfter)) { - 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."); + variantType = VariantAfter.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "after") + if (reader.ValueTextEquals(VariantBefore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBefore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "before") + if (reader.ValueTextEquals(VariantContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "contained_by") + if (reader.ValueTextEquals(VariantContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContaining.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "containing") + if (reader.ValueTextEquals(VariantNotContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "not_contained_by") + if (reader.ValueTextEquals(VariantNotContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContaining.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "not_containing") + if (reader.ValueTextEquals(VariantNotOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "not_overlapping") + if (reader.ValueTextEquals(VariantOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "overlapping") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "script") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.QueryDsl.Intervals)value.Variant, options); - break; - case "before": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Script)value.Variant, options); - break; - } + case "": + break; + case "after": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "before": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "not_contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "not_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "not_overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant, null, null); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Script?)value.Variant, null, null); + 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/_Generated/Types/QueryDsl/IntervalsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs index bf1ea817e74..e2e9dab41b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -39,12 +39,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.QueryDsl.IntervalsAllOf intervalsAllOf) => new IntervalsQuery("all_of", intervalsAllOf); public static IntervalsQuery AnyOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new IntervalsQuery("any_of", intervalsAnyOf); @@ -81,148 +85,145 @@ 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 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.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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); + LocalJsonValue propBoost = default; + LocalJsonValue 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.TryReadProperty(ref reader, options, PropBoost, null)) { - 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 (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (reader.ValueTextEquals(VariantAllOf)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "all_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "wildcard") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.ValidateToken(System.Text.Json.JsonTokenType.EndObject); 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.WritePropertyName(options, value.Field, null); writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) + switch (value.VariantType) { - 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 "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf?)value.Variant, null, null); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf?)value.Variant, null, null); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy?)value.Variant, null, null); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch?)value.Variant, null, null); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix?)value.Variant, null, null); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IntervalsQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Like.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Like.g.cs index f175c27f412..687451cda93 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Like.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Like.g.cs @@ -36,13 +36,52 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(LikeConverter))] public sealed partial class Like : Union { - public Like(string Text) : base(Text) + public Like(string text) : base(text) { } - public Like(Elastic.Clients.Elasticsearch.QueryDsl.LikeDocument Document) : base(Document) + public Like(Elastic.Clients.Elasticsearch.QueryDsl.LikeDocument document) : base(document) { } + + public static implicit operator Like(string text) => new Like(text); + public static implicit operator Like(Elastic.Clients.Elasticsearch.QueryDsl.LikeDocument document) => new Like(document); +} + +internal sealed partial class LikeConverter : System.Text.Json.Serialization.JsonConverter +{ + public override Like Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.String, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new Like(reader.ReadValue(options, null)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new Like(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(Like)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Like value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, null); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs index 181ce211247..041f449356c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs @@ -37,7 +37,6 @@ public sealed partial class LikeDocument [JsonInclude, JsonPropertyName("doc")] public object? Doc { get; set; } [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs index 4d56cdd27b8..b126d7e1413 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs @@ -27,164 +27,158 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new MatchBoolPrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) { - 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.TryReadProperty(ref reader, options, PropBoost, null)) + { + 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.TryReadProperty(ref reader, options, PropFuzziness, null)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryReadProperty(ref reader, options, PropFuzzyRewrite, null)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryReadProperty(ref reader, options, PropFuzzyTranspositions, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propMaxExpansions.TryReadProperty(ref reader, options, PropMaxExpansions, null)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMinimumShouldMatch.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryReadProperty(ref reader, options, PropOperator, null)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryReadProperty(ref reader, options, PropPrefixLength, null)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness, null, null); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite, null, null); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions, null, null); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions, null, null); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropOperator, value.Operator, null, null); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -200,6 +194,10 @@ public MatchBoolPrefixQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs index 3a1f22002b6..9fd6258b31d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs @@ -27,116 +27,118 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new MatchPhrasePrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) { - 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.TryReadProperty(ref reader, options, PropBoost, null)) + { + 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.TryReadProperty(ref reader, options, PropMaxExpansions, null)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryReadProperty(ref reader, options, PropSlop, null)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryReadProperty(ref reader, options, PropZeroTermsQuery, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropSlop, value.Slop, null, null); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +154,10 @@ public MatchPhrasePrefixQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal MatchPhrasePrefixQuery() + { + } + /// /// /// Analyzer used to convert text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs index ff6632c7399..4c55498856f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs @@ -27,104 +27,108 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new MatchPhraseQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) { - 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.TryReadProperty(ref reader, options, PropBoost, null)) + { + 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.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryReadProperty(ref reader, options, PropSlop, null)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryReadProperty(ref reader, options, PropZeroTermsQuery, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropSlop, value.Slop, null, null); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +144,10 @@ public MatchPhraseQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/MatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs index 21611f7384a..ccc512bb206 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs @@ -27,200 +27,188 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new MatchQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) { - 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.TryReadProperty(ref reader, options, PropAutoGenerateSynonymsPhraseQuery, null)) + { + 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.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } - if (value.AutoGenerateSynonymsPhraseQuery.HasValue) - { - writer.WritePropertyName("auto_generate_synonyms_phrase_query"); - writer.WriteBooleanValue(value.AutoGenerateSynonymsPhraseQuery.Value); - } + if (propFuzziness.TryReadProperty(ref reader, options, PropFuzziness, null)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryReadProperty(ref reader, options, PropFuzzyRewrite, null)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryReadProperty(ref reader, options, PropFuzzyTranspositions, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propLenient.TryReadProperty(ref reader, options, PropLenient, null)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMaxExpansions.TryReadProperty(ref reader, options, PropMaxExpansions, null)) + { + continue; + } - if (value.Lenient.HasValue) - { - writer.WritePropertyName("lenient"); - writer.WriteBooleanValue(value.Lenient.Value); - } + if (propMinimumShouldMatch.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryReadProperty(ref reader, options, PropOperator, null)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryReadProperty(ref reader, options, PropPrefixLength, null)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propZeroTermsQuery.TryReadProperty(ref reader, options, PropZeroTermsQuery, null)) + { + continue; + } - if (value.ZeroTermsQuery is not null) - { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer, null, null); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness, null, null); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite, null, null); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions, null, null); + writer.WriteProperty(options, PropLenient, value.Lenient, null, null); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions, null, null); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropOperator, value.Operator, null, null); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -236,6 +224,10 @@ public MatchQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs index 30e777edcfb..35c859171c3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs @@ -27,6 +27,235 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propBoostTerms = default; + LocalJsonValue propFailOnUnsupportedField = default; + LocalJsonValue propFields = default; + LocalJsonValue propInclude = default; + LocalJsonValue> propLike = default; + LocalJsonValue propMaxDocFreq = default; + LocalJsonValue propMaxQueryTerms = default; + LocalJsonValue propMaxWordLength = default; + LocalJsonValue propMinDocFreq = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propMinTermFreq = default; + LocalJsonValue propMinWordLength = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRouting = default; + LocalJsonValue?> propStopWords = default; + LocalJsonValue?> propUnlike = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propBoostTerms.TryReadProperty(ref reader, options, PropBoostTerms, null)) + { + continue; + } + + if (propFailOnUnsupportedField.TryReadProperty(ref reader, options, PropFailOnUnsupportedField, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propInclude.TryReadProperty(ref reader, options, PropInclude, null)) + { + continue; + } + + if (propLike.TryReadProperty(ref reader, options, PropLike, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propMaxDocFreq.TryReadProperty(ref reader, options, PropMaxDocFreq, null)) + { + continue; + } + + if (propMaxQueryTerms.TryReadProperty(ref reader, options, PropMaxQueryTerms, null)) + { + continue; + } + + if (propMaxWordLength.TryReadProperty(ref reader, options, PropMaxWordLength, null)) + { + continue; + } + + if (propMinDocFreq.TryReadProperty(ref reader, options, PropMinDocFreq, null)) + { + continue; + } + + if (propMinimumShouldMatch.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + continue; + } + + if (propMinTermFreq.TryReadProperty(ref reader, options, PropMinTermFreq, null)) + { + continue; + } + + if (propMinWordLength.TryReadProperty(ref reader, options, PropMinWordLength, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propRouting.TryReadProperty(ref reader, options, PropRouting, null)) + { + continue; + } + + if (propStopWords.TryReadProperty(ref reader, options, PropStopWords, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propUnlike.TryReadProperty(ref reader, options, PropUnlike, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propVersion.TryReadProperty(ref reader, options, PropVersion, null)) + { + continue; + } + + if (propVersionType.TryReadProperty(ref reader, options, PropVersionType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropBoostTerms, value.BoostTerms, null, null); + writer.WriteProperty(options, PropFailOnUnsupportedField, value.FailOnUnsupportedField, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropInclude, value.Include, null, null); + writer.WriteProperty(options, PropLike, value.Like, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMaxDocFreq, value.MaxDocFreq, null, null); + writer.WriteProperty(options, PropMaxQueryTerms, value.MaxQueryTerms, null, null); + writer.WriteProperty(options, PropMaxWordLength, value.MaxWordLength, null, null); + writer.WriteProperty(options, PropMinDocFreq, value.MinDocFreq, null, null); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropMinTermFreq, value.MinTermFreq, null, null); + writer.WriteProperty(options, PropMinWordLength, value.MinWordLength, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRouting, value.Routing, null, null); + writer.WriteProperty(options, PropStopWords, value.StopWords, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropUnlike, value.Unlike, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropVersion, value.Version, null, null); + writer.WriteProperty(options, PropVersionType, value.VersionType, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MoreLikeThisQueryConverter))] public sealed partial class MoreLikeThisQuery { /// @@ -35,7 +264,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 +274,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 +283,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to deactivated (0). /// /// - [JsonInclude, JsonPropertyName("boost_terms")] public double? BoostTerms { get; set; } /// @@ -64,7 +290,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 +298,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.Fields? Fields { get; set; } /// @@ -82,7 +305,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 +312,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.QueryDsl.Like))] public ICollection Like { get; set; } /// @@ -99,7 +319,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 +326,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 +334,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to unbounded (0). /// /// - [JsonInclude, JsonPropertyName("max_word_length")] public int? MaxWordLength { get; set; } /// @@ -124,7 +341,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 +348,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.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -140,7 +355,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 +362,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.Routing? Routing { get; set; } /// @@ -161,8 +372,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 +379,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.QueryDsl.Like))] public ICollection? Unlike { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(MoreLikeThisQuery moreLikeThisQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.MoreLikeThis(moreLikeThisQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs index 8a01d0b1f4c..c3c26d7a514 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs @@ -27,6 +27,215 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFields = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propTieBreaker = default; + LocalJsonValue propType = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryReadProperty(ref reader, options, PropAnalyzer, null)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryReadProperty(ref reader, options, PropAutoGenerateSynonymsPhraseQuery, null)) + { + continue; + } + + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker)))) + { + continue; + } + + if (propFuzziness.TryReadProperty(ref reader, options, PropFuzziness, null)) + { + continue; + } + + if (propFuzzyRewrite.TryReadProperty(ref reader, options, PropFuzzyRewrite, null)) + { + continue; + } + + if (propFuzzyTranspositions.TryReadProperty(ref reader, options, PropFuzzyTranspositions, null)) + { + continue; + } + + if (propLenient.TryReadProperty(ref reader, options, PropLenient, null)) + { + continue; + } + + if (propMaxExpansions.TryReadProperty(ref reader, options, PropMaxExpansions, null)) + { + continue; + } + + if (propMinimumShouldMatch.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + continue; + } + + if (propOperator.TryReadProperty(ref reader, options, PropOperator, null)) + { + continue; + } + + if (propPrefixLength.TryReadProperty(ref reader, options, PropPrefixLength, null)) + { + continue; + } + + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propSlop.TryReadProperty(ref reader, options, PropSlop, null)) + { + continue; + } + + if (propTieBreaker.TryReadProperty(ref reader, options, PropTieBreaker, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (propZeroTermsQuery.TryReadProperty(ref reader, options, PropZeroTermsQuery, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery, null, null); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields? v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness, null, null); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite, null, null); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions, null, null); + writer.WriteProperty(options, PropLenient, value.Lenient, null, null); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions, null, null); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropOperator, value.Operator, null, null); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropSlop, value.Slop, null, null); + writer.WriteProperty(options, PropTieBreaker, value.TieBreaker, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiMatchQueryConverter))] public sealed partial class MultiMatchQuery { /// @@ -34,7 +243,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 +250,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 +260,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 +268,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.Fields? Fields { get; set; } /// @@ -71,7 +275,6 @@ public sealed partial class MultiMatchQuery /// Maximum edit distance allowed for matching. /// /// - [JsonInclude, JsonPropertyName("fuzziness")] public Elastic.Clients.Elasticsearch.Fuzziness? Fuzziness { get; set; } /// @@ -79,7 +282,6 @@ public sealed partial class MultiMatchQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("fuzzy_rewrite")] public string? FuzzyRewrite { get; set; } /// @@ -88,7 +290,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 +297,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 +304,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 +311,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.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -120,7 +318,6 @@ public sealed partial class MultiMatchQuery /// Boolean logic used to interpret text in the query value. /// /// - [JsonInclude, JsonPropertyName("operator")] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? Operator { get; set; } /// @@ -128,7 +325,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 +332,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 +340,6 @@ public sealed partial class MultiMatchQuery /// Maximum number of positions allowed between matching tokens. /// /// - [JsonInclude, JsonPropertyName("slop")] public int? Slop { get; set; } /// @@ -154,7 +347,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 +354,6 @@ public sealed partial class MultiMatchQuery /// How the multi_match query is executed internally. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryDsl.TextQueryType? Type { get; set; } /// @@ -170,7 +361,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.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(MultiMatchQuery multiMatchQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.MultiMatch(multiMatchQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs index cfbc2a0079e..c54476c6db3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs @@ -27,127 +27,118 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new NumberRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropGt, null)) + { + 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.TryReadProperty(ref reader, options, PropGte, null)) + { + continue; + } - if (value.Gt.HasValue) - { - writer.WritePropertyName("gt"); - writer.WriteNumberValue(value.Gt.Value); - } + if (propLt.TryReadProperty(ref reader, options, PropLt, null)) + { + continue; + } - if (value.Gte.HasValue) - { - writer.WritePropertyName("gte"); - writer.WriteNumberValue(value.Gte.Value); - } + if (propLte.TryReadProperty(ref reader, options, PropLte, null)) + { + continue; + } - if (value.Lt.HasValue) - { - writer.WritePropertyName("lt"); - writer.WriteNumberValue(value.Lt.Value); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.Lte.HasValue) - { - writer.WritePropertyName("lte"); - writer.WriteNumberValue(value.Lte.Value); - } + if (propRelation.TryReadProperty(ref reader, options, PropRelation, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropGt, value.Gt, null, null); + writer.WriteProperty(options, PropGte, value.Gte, null, null); + writer.WriteProperty(options, PropLt, value.Lt, null, null); + writer.WriteProperty(options, PropLte, value.Lte, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRelation, value.Relation, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(NumberRangeQueryConverter))] -public sealed partial class NumberRangeQuery +public sealed partial class NumberRangeQuery : IRangeQuery { public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -156,6 +147,10 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal NumberRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +197,8 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public Elastic.Clients.Elasticsearch.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "numberrangequery"; } public sealed partial class NumberRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs index 7b69411a236..b973e5d5d5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs @@ -27,60 +27,49 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryReadProperty(ref reader, options, PropMultiValueMode, null)) { - 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, null, null); } - 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, null, null); + writer.WriteProperty(options, value.Field, value.Placement, null, null); writer.WriteEndObject(); } } [JsonConverter(typeof(NumericDecayFunctionConverter))] -public sealed partial class NumericDecayFunction +public sealed partial class NumericDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +80,8 @@ public sealed partial class NumericDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "numericdecayfunction"; } public sealed partial class NumericDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs index 26dd33fbbfb..398a25c0807 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs @@ -39,12 +39,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 +87,96 @@ 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.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); + LocalJsonValue propBoost = default; + LocalJsonValue propOrganic = default; + LocalJsonValue 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.TryReadProperty(ref reader, options, PropBoost, null)) { - 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 (propOrganic.TryReadProperty(ref reader, options, PropOrganic, null)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "organic") + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) { - organicValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (reader.ValueTextEquals(VariantDocs)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantDocs.Value; + reader.Read(); + variant = reader.ReadValue?>(options, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)); continue; } - if (propertyName == "docs") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue?>(options, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)); continue; } - if (propertyName == "ids") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (ICollection?)value.Variant, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteCollectionValue(o, v, null)); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(PinnedQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropOrganic, value.Organic, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs index bf5373da149..1677b289aa0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs @@ -27,92 +27,98 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new PrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options, null); + reader.Read(); + return new PrefixQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropCaseInsensitive, null)) + { + 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryReadProperty(ref reader, options, PropRewrite, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRewrite, value.Rewrite, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -128,6 +134,10 @@ public PrefixQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/Query.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs index 35c8ba75904..5221bbc372e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs @@ -39,18 +39,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.QueryDsl.BoolQuery boolQuery) => new Query("bool", boolQuery); public static Query Boosting(Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery boostingQuery) => new Query("boosting", boostingQuery); public static Query CombinedFields(Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery combinedFieldsQuery) => new Query("combined_fields", combinedFieldsQuery); public static Query ConstantScore(Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery constantScoreQuery) => new Query("constant_score", constantScoreQuery); public static Query DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => new Query("dis_max", disMaxQuery); + public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); @@ -79,6 +84,7 @@ internal Query(string variantName, object variant) public static Query Pinned(Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery pinnedQuery) => new Query("pinned", pinnedQuery); public static Query Prefix(Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery prefixQuery) => new Query("prefix", prefixQuery); public static Query QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => new Query("query_string", queryStringQuery); + public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => new Query("range", rangeQuery); @@ -121,607 +127,709 @@ 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) + if (reader.ValueTextEquals(VariantBool)) { - 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."); + variantType = VariantBool.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bool") + if (reader.ValueTextEquals(VariantBoosting)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoosting.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "boosting") + if (reader.ValueTextEquals(VariantCombinedFields)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCombinedFields.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "combined_fields") + if (reader.ValueTextEquals(VariantConstantScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConstantScore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "constant_score") + if (reader.ValueTextEquals(VariantDisMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDisMax.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "dis_max") + if (reader.ValueTextEquals(VariantDistanceFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDistanceFeature.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "distance_feature") + if (reader.ValueTextEquals(VariantExists)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExists.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "exists") + if (reader.ValueTextEquals(VariantFunctionScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFunctionScore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "function_score") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantGeoBoundingBox)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBoundingBox.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_bounding_box") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeoShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoShape.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "geo_shape") + if (reader.ValueTextEquals(VariantHasChild)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasChild.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "has_child") + if (reader.ValueTextEquals(VariantHasParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasParent.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "has_parent") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "ids") + if (reader.ValueTextEquals(VariantIntervals)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIntervals.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "intervals") + if (reader.ValueTextEquals(VariantKnn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "knn") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatchAll)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchAll.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match_all") + if (reader.ValueTextEquals(VariantMatchBoolPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchBoolPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match_bool_prefix") + if (reader.ValueTextEquals(VariantMatchNone)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchNone.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match_none") + if (reader.ValueTextEquals(VariantMatchPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match_phrase") + if (reader.ValueTextEquals(VariantMatchPhrasePrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrasePrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "match_phrase_prefix") + if (reader.ValueTextEquals(VariantMoreLikeThis)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMoreLikeThis.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "more_like_this") + if (reader.ValueTextEquals(VariantMultiMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiMatch.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "multi_match") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantParentId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParentId.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "parent_id") + if (reader.ValueTextEquals(VariantPercolate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercolate.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "percolate") + if (reader.ValueTextEquals(VariantPinned)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPinned.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "pinned") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "query_string") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRankFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRankFeature.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rank_feature") + if (reader.ValueTextEquals(VariantRawJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRawJson.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "raw_json") + if (reader.ValueTextEquals(VariantRegexp)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegexp.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "regexp") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "script_score") + if (reader.ValueTextEquals(VariantSemantic)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSemantic.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "semantic") + if (reader.ValueTextEquals(VariantShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantShape.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "shape") + if (reader.ValueTextEquals(VariantSimpleQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSimpleQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "simple_query_string") + if (reader.ValueTextEquals(VariantSpanContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_containing") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_within") + if (reader.ValueTextEquals(VariantSparseVector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSparseVector.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "sparse_vector") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "term") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTermsSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTermsSet.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "terms_set") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWrapper)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWrapper.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "wrapper") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.QueryDsl.BoolQuery)value.Variant, options); - break; - case "boosting": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery)value.Variant, options); - break; - case "combined_fields": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery)value.Variant, options); - break; - case "constant_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery)value.Variant, options); - break; - case "dis_max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.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.QueryDsl.ExistsQuery)value.Variant, options); - break; - case "function_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreQuery)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.FuzzyQuery)value.Variant, options); - break; - case "geo_bounding_box": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoBoundingBoxQuery)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceQuery)value.Variant, options); - break; - case "geo_shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoShapeQuery)value.Variant, options); - break; - case "has_child": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.HasChildQuery)value.Variant, options); - break; - case "has_parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.HasParentQuery)value.Variant, options); - break; - case "ids": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IdsQuery)value.Variant, options); - break; - case "intervals": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery)value.Variant, options); - break; - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.KnnQuery)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery)value.Variant, options); - break; - case "match_all": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchAllQuery)value.Variant, options); - break; - case "match_bool_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchBoolPrefixQuery)value.Variant, options); - break; - case "match_none": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchNoneQuery)value.Variant, options); - break; - case "match_phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhraseQuery)value.Variant, options); - break; - case "match_phrase_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhrasePrefixQuery)value.Variant, options); - break; - case "more_like_this": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MoreLikeThisQuery)value.Variant, options); - break; - case "multi_match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MultiMatchQuery)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.NestedQuery)value.Variant, options); - break; - case "parent_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ParentIdQuery)value.Variant, options); - break; - case "percolate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PercolateQuery)value.Variant, options); - break; - case "pinned": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery)value.Variant, options); - break; - case "query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.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.QueryDsl.RankFeatureQuery)value.Variant, options); - break; - case "raw_json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RawJsonQuery)value.Variant, options); - break; - case "regexp": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RegexpQuery)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RuleQuery)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery)value.Variant, options); - break; - case "semantic": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SemanticQuery)value.Variant, options); - break; - case "shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery)value.Variant, options); - break; - case "simple_query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery)value.Variant, options); - break; - case "span_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery)value.Variant, options); - break; - case "span_multi": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - case "sparse_vector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SparseVectorQuery)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermQuery)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermsQuery)value.Variant, options); - break; - case "terms_set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermsSetQuery)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.WildcardQuery)value.Variant, options); - break; - case "wrapper": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.WrapperQuery)value.Variant, options); - break; - } + case "": + break; + case "bool": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.BoolQuery?)value.Variant, null, null); + break; + case "boosting": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery?)value.Variant, null, null); + break; + case "combined_fields": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery?)value.Variant, null, null); + break; + case "constant_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery?)value.Variant, null, null); + break; + case "dis_max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery?)value.Variant, null, null); + break; + case "distance_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery)value.Variant, null, null); + break; + case "exists": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ExistsQuery?)value.Variant, null, null); + break; + case "function_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreQuery?)value.Variant, null, null); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FuzzyQuery?)value.Variant, null, null); + break; + case "geo_bounding_box": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoBoundingBoxQuery?)value.Variant, null, null); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceQuery?)value.Variant, null, null); + break; + case "geo_shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoShapeQuery?)value.Variant, null, null); + break; + case "has_child": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.HasChildQuery?)value.Variant, null, null); + break; + case "has_parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.HasParentQuery?)value.Variant, null, null); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IdsQuery?)value.Variant, null, null); + break; + case "intervals": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery?)value.Variant, null, null); + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.KnnQuery?)value.Variant, null, null); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery?)value.Variant, null, null); + break; + case "match_all": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchAllQuery?)value.Variant, null, null); + break; + case "match_bool_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchBoolPrefixQuery?)value.Variant, null, null); + break; + case "match_none": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchNoneQuery?)value.Variant, null, null); + break; + case "match_phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhraseQuery?)value.Variant, null, null); + break; + case "match_phrase_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhrasePrefixQuery?)value.Variant, null, null); + break; + case "more_like_this": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MoreLikeThisQuery?)value.Variant, null, null); + break; + case "multi_match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MultiMatchQuery?)value.Variant, null, null); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.NestedQuery?)value.Variant, null, null); + break; + case "parent_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ParentIdQuery?)value.Variant, null, null); + break; + case "percolate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PercolateQuery?)value.Variant, null, null); + break; + case "pinned": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery?)value.Variant, null, null); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery?)value.Variant, null, null); + break; + case "query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery?)value.Variant, null, null); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery)value.Variant, null, null); + break; + case "rank_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RankFeatureQuery?)value.Variant, null, null); + break; + case "raw_json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RawJsonQuery?)value.Variant, null, null); + break; + case "regexp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RegexpQuery?)value.Variant, null, null); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RuleQuery?)value.Variant, null, null); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery?)value.Variant, null, null); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery?)value.Variant, null, null); + break; + case "semantic": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SemanticQuery?)value.Variant, null, null); + break; + case "shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery?)value.Variant, null, null); + break; + case "simple_query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery?)value.Variant, null, null); + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery?)value.Variant, null, null); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery?)value.Variant, null, null); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery?)value.Variant, null, null); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery?)value.Variant, null, null); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery?)value.Variant, null, null); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery?)value.Variant, null, null); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery?)value.Variant, null, null); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery?)value.Variant, null, null); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery?)value.Variant, null, null); + break; + case "sparse_vector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SparseVectorQuery?)value.Variant, null, null); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermQuery?)value.Variant, null, null); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermsQuery?)value.Variant, null, null); + break; + case "terms_set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermsSetQuery?)value.Variant, null, null); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.WildcardQuery?)value.Variant, null, null); + break; + case "wrapper": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.WrapperQuery?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Query)}'."); } writer.WriteEndObject(); @@ -769,6 +877,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action> configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action> configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -822,6 +931,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action> configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action> configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); @@ -935,6 +1045,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -988,6 +1099,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs index c805604bc93..d4003f29b95 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs @@ -106,7 +106,6 @@ public sealed partial class QueryStringQuery /// /// [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs new file mode 100644 index 00000000000..9210eb3e35d --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs @@ -0,0 +1,63 @@ +// 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.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.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, null); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.TermRangeQuery v: + writer.WriteValue(options, v, null); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery v: + writer.WriteValue(options, v, null); + 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/_Generated/Types/QueryDsl/RegexpQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs index 4d47a0cbec5..7d372c9746d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs @@ -27,116 +27,118 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new RegexpQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propFlags = default; + LocalJsonValue propMaxDeterminizedStates = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropCaseInsensitive, null)) + { + 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.TryReadProperty(ref reader, options, PropFlags, null)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propMaxDeterminizedStates.TryReadProperty(ref reader, options, PropMaxDeterminizedStates, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Flags)) - { - writer.WritePropertyName("flags"); - writer.WriteStringValue(value.Flags); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.MaxDeterminizedStates.HasValue) - { - writer.WritePropertyName("max_determinized_states"); - writer.WriteNumberValue(value.MaxDeterminizedStates.Value); - } + if (propRewrite.TryReadProperty(ref reader, options, PropRewrite, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive, null, null); + writer.WriteProperty(options, PropFlags, value.Flags, null, null); + writer.WriteProperty(options, PropMaxDeterminizedStates, value.MaxDeterminizedStates, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRewrite, value.Rewrite, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +154,10 @@ public RegexpQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/ShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs index 9b313e9a20a..6062d28b355 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs @@ -27,78 +27,63 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue propShape = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropIgnoreUnmapped, null)) { - 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + 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, null, null); } - 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, null, null); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, value.Field, value.Shape, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs index 14e77720775..893143dd738 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs @@ -81,7 +81,6 @@ public sealed partial class SimpleQueryStringQuery /// /// [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs index 68096795d8c..002926025ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs @@ -39,12 +39,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.QueryDsl.SpanContainingQuery spanContainingQuery) => new SpanQuery("span_containing", spanContainingQuery); public static SpanQuery SpanFieldMasking(Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery spanFieldMaskingQuery) => new SpanQuery("span_field_masking", spanFieldMaskingQuery); @@ -70,147 +74,157 @@ 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) + if (reader.ValueTextEquals(VariantSpanContaining)) { - 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."); + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "span_containing") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanGap)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanGap.Value; + reader.Read(); + variant = reader.ReadValue?>(options, null); continue; } - if (propertyName == "span_gap") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "span_within") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.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.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - } + case "": + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery?)value.Variant, null, null); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery?)value.Variant, null, null); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery?)value.Variant, null, null); + break; + case "span_gap": + writer.WriteProperty(options, value.VariantType, (KeyValuePair?)value.Variant, null, null); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery?)value.Variant, null, null); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery?)value.Variant, null, null); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery?)value.Variant, null, null); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery?)value.Variant, null, null); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery?)value.Variant, null, null); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery?)value.Variant, null, null); + 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/_Generated/Types/QueryDsl/SpanTermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs index 80695af511c..af68b2dc394 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs @@ -27,68 +27,78 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new SpanTermQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) { - 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; } + + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); 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, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -104,6 +114,10 @@ public SpanTermQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs index cb6c959ad3d..6e0ba6280a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs @@ -39,12 +39,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.Id id) => new SparseVectorQuery("inference_id", id); @@ -113,143 +117,114 @@ 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) + 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 PropPrune = System.Text.Json.JsonEncodedText.Encode("prune"); + private static readonly System.Text.Json.JsonEncodedText PropPruningConfig = System.Text.Json.JsonEncodedText.Encode("pruning_config"); + 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"); + + public override SparseVectorQuery 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; - float? boostValue = default; - Elastic.Clients.Elasticsearch.Field fieldValue = default; - bool? pruneValue = default; - Elastic.Clients.Elasticsearch.QueryDsl.TokenPruningConfig? pruningConfigValue = default; - string? queryValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue propPrune = default; + LocalJsonValue propPruningConfig = default; + LocalJsonValue propQuery = default; + LocalJsonValue 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.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropField, null)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "field") + if (propPrune.TryReadProperty(ref reader, options, PropPrune, null)) { - fieldValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "prune") + if (propPruningConfig.TryReadProperty(ref reader, options, PropPruningConfig, null)) { - pruneValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "pruning_config") + if (propQuery.TryReadProperty(ref reader, options, PropQuery, null)) { - pruningConfigValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "query") + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) { - queryValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (reader.ValueTextEquals(VariantInferenceId)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); + variantType = VariantInferenceId.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "inference_id") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.Prune = pruneValue; - result.PruningConfig = pruningConfigValue; - 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 + , + Prune = propPrune.Value + , + PruningConfig = propPruningConfig.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 (value.Prune.HasValue) - { - writer.WritePropertyName("prune"); - writer.WriteBooleanValue(value.Prune.Value); - } - - if (value.PruningConfig is not null) + switch (value.VariantType) { - writer.WritePropertyName("pruning_config"); - JsonSerializer.Serialize(writer, value.PruningConfig, 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) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "inference_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Id)value.Variant, options); - break; - } + case "": + break; + case "inference_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Id?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SparseVectorQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropField, value.Field, null, null); + writer.WriteProperty(options, PropPrune, value.Prune, null, null); + writer.WriteProperty(options, PropPruningConfig, value.PruningConfig, null, null); + writer.WriteProperty(options, PropQuery, value.Query, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs index 3a3e17909a0..2748519f8cc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs @@ -27,80 +27,88 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new TermQuery(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, null); + reader.Read(); + return new TermQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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; - } + continue; } + + if (propCaseInsensitive.TryReadProperty(ref reader, options, PropCaseInsensitive, null)) + { + continue; + } + + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } + + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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 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, null); 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, null, null); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -116,6 +124,10 @@ public TermQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/TermRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs index 5e175e78f1b..5c9c4fddb27 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs @@ -27,127 +27,118 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new TermRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropGt, null)) + { + 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.TryReadProperty(ref reader, options, PropGte, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gt)) - { - writer.WritePropertyName("gt"); - writer.WriteStringValue(value.Gt); - } + if (propLt.TryReadProperty(ref reader, options, PropLt, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gte)) - { - writer.WritePropertyName("gte"); - writer.WriteStringValue(value.Gte); - } + if (propLte.TryReadProperty(ref reader, options, PropLte, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lt)) - { - writer.WritePropertyName("lt"); - writer.WriteStringValue(value.Lt); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lte)) - { - writer.WritePropertyName("lte"); - writer.WriteStringValue(value.Lte); - } + if (propRelation.TryReadProperty(ref reader, options, PropRelation, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropGt, value.Gt, null, null); + writer.WriteProperty(options, PropGte, value.Gte, null, null); + writer.WriteProperty(options, PropLt, value.Lt, null, null); + writer.WriteProperty(options, PropLte, value.Lte, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRelation, value.Relation, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(TermRangeQueryConverter))] -public sealed partial class TermRangeQuery +public sealed partial class TermRangeQuery : IRangeQuery { public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -156,6 +147,10 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal TermRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +197,8 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public Elastic.Clients.Elasticsearch.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "termrangequery"; } public sealed partial class TermRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs index a56cf458603..45e34690ccf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs @@ -27,66 +27,53 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue propTerms = default; + LocalJsonValue propBoost = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropQueryName, null)) { - 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, null, null); } - 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, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, value.Field, value.Terms, null, null); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQueryField.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQueryField.g.cs index 3f56dc6eba9..9cbccc9f9e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQueryField.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQueryField.g.cs @@ -30,13 +30,49 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class TermsQueryField : Union, Elastic.Clients.Elasticsearch.QueryDsl.TermsLookup> +[JsonConverter(typeof(TermsQueryFieldConverter))] +public sealed partial class TermsQueryField : Union, Elastic.Clients.Elasticsearch.QueryDsl.TermsLookup> { - public TermsQueryField(IReadOnlyCollection Value) : base(Value) + public TermsQueryField(ICollection value) : base(value) { } - public TermsQueryField(Elastic.Clients.Elasticsearch.QueryDsl.TermsLookup Lookup) : base(Lookup) + public TermsQueryField(Elastic.Clients.Elasticsearch.QueryDsl.TermsLookup lookup) : base(lookup) { } +} + +internal sealed partial class TermsQueryFieldConverter : System.Text.Json.Serialization.JsonConverter +{ + public override TermsQueryField Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var selector = static (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => JsonUnionSelector.ByTokenType(ref r, o, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartArray, Elastic.Clients.Elasticsearch.Serialization.JsonTokenTypes.StartObject); + return selector(ref reader, options) switch + { + Elastic.Clients.Elasticsearch.UnionTag.T1 => new TermsQueryField(reader.ReadValue>(options, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)), + Elastic.Clients.Elasticsearch.UnionTag.T2 => new TermsQueryField(reader.ReadValue(options, null)), + _ => throw new System.InvalidOperationException($"Failed to select a union variant for type '{nameof(TermsQueryField)}") + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsQueryField value, System.Text.Json.JsonSerializerOptions options) + { + switch (value.Tag) + { + case Elastic.Clients.Elasticsearch.UnionTag.T1: + { + writer.WriteValue(options, value.Value1, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + break; + } + + case Elastic.Clients.Elasticsearch.UnionTag.T2: + { + writer.WriteValue(options, value.Value2, null); + break; + } + + default: + throw new System.InvalidOperationException($"Unrecognized tag value: {value.Tag}"); + } + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs index 47cb8cf5415..82776e30254 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs @@ -27,104 +27,101 @@ namespace Elastic.Clients.Elasticsearch.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) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + 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) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new TermsSetQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propMinimumShouldMatchField = default; + LocalJsonValue propMinimumShouldMatchScript = default; + LocalJsonValue propQueryName = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropMinimumShouldMatch, null)) + { + 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.TryReadProperty(ref reader, options, PropMinimumShouldMatchField, null)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propMinimumShouldMatchScript.TryReadProperty(ref reader, options, PropMinimumShouldMatchScript, null)) + { + continue; + } - if (value.MinimumShouldMatchField is not null) - { - writer.WritePropertyName("minimum_should_match_field"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchField, options); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.MinimumShouldMatchScript is not null) - { - writer.WritePropertyName("minimum_should_match_script"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchScript, options); - } + if (propTerms.TryReadProperty(ref reader, options, PropTerms, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch, null, null); + writer.WriteProperty(options, PropMinimumShouldMatchField, value.MinimumShouldMatchField, null, null); + writer.WriteProperty(options, PropMinimumShouldMatchScript, value.MinimumShouldMatchScript, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropTerms, value.Terms, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +137,10 @@ public TermsSetQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs index 0972c6b4a4a..2c0557a01cf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs @@ -27,60 +27,49 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryReadProperty(ref reader, options, PropMultiValueMode, null)) { - 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, null, null); } - 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, null, null); + writer.WriteProperty(options, value.Field, value.Placement, null, null); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedDecayFunctionConverter))] -public sealed partial class UntypedDecayFunction +public sealed partial class UntypedDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +80,8 @@ public sealed partial class UntypedDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "untypeddecayfunction"; } public sealed partial class UntypedDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs index 728ae35facf..9df04c7c815 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs index 582463372a6..7a4f18a83b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs @@ -27,151 +27,138 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); reader.Read(); - var variant = new UntypedRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropFormat, null)) + { + 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.TryReadProperty(ref reader, options, PropGt, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryReadProperty(ref reader, options, PropGte, null)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryReadProperty(ref reader, options, PropLt, null)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryReadProperty(ref reader, options, PropLte, null)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryReadProperty(ref reader, options, PropRelation, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryReadProperty(ref reader, options, PropTimeZone, null)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropFormat, value.Format, null, null); + writer.WriteProperty(options, PropGt, value.Gt, null, null); + writer.WriteProperty(options, PropGte, value.Gte, null, null); + writer.WriteProperty(options, PropLt, value.Lt, null, null); + writer.WriteProperty(options, PropLte, value.Lte, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRelation, value.Relation, null, null); + writer.WriteProperty(options, PropTimeZone, value.TimeZone, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedRangeQueryConverter))] -public sealed partial class UntypedRangeQuery +public sealed partial class UntypedRangeQuery : IRangeQuery { public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -180,6 +167,10 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal UntypedRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +231,8 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "untypedrangequery"; } public sealed partial class UntypedRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs index 5b449de8d98..e80191ccc9b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs @@ -27,108 +27,108 @@ namespace Elastic.Clients.Elasticsearch.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 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); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options, null); 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, null); + reader.Read(); + return new WildcardQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + LocalJsonValue propWildcard = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryReadProperty(ref reader, options, PropBoost, null)) { - 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.TryReadProperty(ref reader, options, PropCaseInsensitive, null)) + { + 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.TryReadProperty(ref reader, options, PropQueryName, null)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryReadProperty(ref reader, options, PropRewrite, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propValue.TryReadProperty(ref reader, options, PropValue, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + if (propWildcard.TryReadProperty(ref reader, options, PropWildcard, null)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Value)) - { - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost, null, null); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive, null, null); + writer.WriteProperty(options, PropQueryName, value.QueryName, null, null); + writer.WriteProperty(options, PropRewrite, value.Rewrite, null, null); + writer.WriteProperty(options, PropValue, value.Value, null, null); + writer.WriteProperty(options, PropWildcard, value.Wildcard, null, null); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -144,6 +144,10 @@ public WildcardQuery(Elastic.Clients.Elasticsearch.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/_Generated/Types/QueryRules/QueryRule.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs index fc8f7a84ead..db712c64d4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs @@ -27,18 +27,91 @@ namespace Elastic.Clients.Elasticsearch.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); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propRuleId = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryReadProperty(ref reader, options, PropActions, null)) + { + continue; + } + + if (propCriteria.TryReadProperty(ref reader, options, PropCriteria, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null)!)) + { + continue; + } + + if (propPriority.TryReadProperty(ref reader, options, PropPriority, null)) + { + continue; + } + + if (propRuleId.TryReadProperty(ref reader, options, PropRuleId, null)) + { + continue; + } + + if (propType.TryReadProperty(ref reader, options, PropType, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, null); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropPriority, value.Priority, null, null); + writer.WriteProperty(options, PropRuleId, value.RuleId, null, null); + writer.WriteProperty(options, PropType, value.Type, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRuleConverter))] public sealed partial class QueryRule { - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; set; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("rule_id")] public Elastic.Clients.Elasticsearch.Id RuleId { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs index 77354d637e6..52d885e7a20 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs @@ -39,12 +39,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.TextEmbedding textEmbedding) => new QueryVectorBuilder("text_embedding", textEmbedding); @@ -61,57 +65,49 @@ 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."); + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - if (reader.TokenType != JsonTokenType.PropertyName) + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + reader.Skip(); } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "text_embedding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - 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.TextEmbedding)value.Variant, options); - break; - } + case "": + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.TextEmbedding?)value.Variant, null, null); + 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/_Generated/Types/RRFRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs index 62c90d43295..67686d3e3e2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs @@ -27,6 +27,85 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue?> propFilter = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propRankConstant = default; + LocalJsonValue propRankWindowSize = default; + LocalJsonValue> propRetrievers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } + + if (propRankConstant.TryReadProperty(ref reader, options, PropRankConstant, null)) + { + continue; + } + + if (propRankWindowSize.TryReadProperty(ref reader, options, PropRankWindowSize, null)) + { + continue; + } + + if (propRetrievers.TryReadProperty(ref reader, options, PropRetrievers, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropRankConstant, value.RankConstant, null, null); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize, null, null); + writer.WriteProperty(options, PropRetrievers, value.Retrievers, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RRFRetrieverConverter))] public sealed partial class RRFRetriever { /// @@ -34,8 +113,6 @@ public sealed partial class RRFRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +120,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 +127,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 +134,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 +141,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.Retriever(RRFRetriever rRFRetriever) => Elastic.Clients.Elasticsearch.Retriever.Rrf(rRFRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs index 272931dfaa7..970a1c88ae5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs @@ -39,12 +39,16 @@ internal Rank(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 Rank() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Rank Rrf(Elastic.Clients.Elasticsearch.RrfRank rrfRank) => new Rank("rrf", rrfRank); @@ -61,57 +65,49 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RankConverter : JsonConverter +internal sealed partial class RankConverter : System.Text.Json.Serialization.JsonConverter { - public override Rank 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 VariantRrf = System.Text.Json.JsonEncodedText.Encode("rrf"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Rank 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(VariantRrf)) { - throw new JsonException("Expected a property name token."); + variantType = VariantRrf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - if (reader.TokenType != JsonTokenType.PropertyName) + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + reader.Skip(); } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "rrf") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; - } - - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Rank' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Rank(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Rank { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Rank value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Rank 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 "rrf": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RrfRank)value.Variant, options); - break; - } + case "": + break; + case "rrf": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RrfRank?)value.Variant, null, null); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Rank)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs index 5a79a236a6a..7c9507b633d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs @@ -39,12 +39,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.KnnRetriever knnRetriever) => new Retriever("knn", knnRetriever); public static Retriever Rrf(Elastic.Clients.Elasticsearch.RRFRetriever rRFRetriever) => new Retriever("rrf", rRFRetriever); @@ -65,97 +69,97 @@ 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."); + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options, null); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "knn") + if (reader.ValueTextEquals(VariantRrf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRrf.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rrf") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantStandard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStandard.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "standard") + if (reader.ValueTextEquals(VariantTextSimilarityReranker)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextSimilarityReranker.Value; + reader.Read(); + variant = reader.ReadValue(options, null); continue; } - if (propertyName == "text_similarity_reranker") + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; - continue; + reader.Skip(); } - 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.KnnRetriever)value.Variant, options); - break; - case "rrf": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RRFRetriever)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RuleRetriever)value.Variant, options); - break; - case "standard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.StandardRetriever)value.Variant, options); - break; - case "text_similarity_reranker": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.TextSimilarityReranker)value.Variant, options); - break; - } + case "": + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.KnnRetriever?)value.Variant, null, null); + break; + case "rrf": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RRFRetriever?)value.Variant, null, null); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RuleRetriever?)value.Variant, null, null); + break; + case "standard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.StandardRetriever?)value.Variant, null, null); + break; + case "text_similarity_reranker": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.TextSimilarityReranker?)value.Variant, null, null); + 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/_Generated/Types/Rollup/HistogramGrouping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs index 01f81c216af..990d9f49443 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs @@ -27,6 +27,55 @@ namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class HistogramGroupingConverter : 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 PropInterval = System.Text.Json.JsonEncodedText.Encode("interval"); + + public override HistogramGrouping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue propInterval = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (propInterval.TryReadProperty(ref reader, options, PropInterval, null)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramGrouping + { + Fields = propFields.Value +, + Interval = propInterval.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramGrouping value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteProperty(options, PropInterval, value.Interval, null, null); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HistogramGroupingConverter))] public sealed partial class HistogramGrouping { /// @@ -36,8 +85,6 @@ public sealed partial class HistogramGrouping /// Order does not matter. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// @@ -47,7 +94,6 @@ public sealed partial class HistogramGrouping /// Note that only one interval can be specified in the histogram group, meaning that all fields being grouped via the histogram must share the same interval. /// /// - [JsonInclude, JsonPropertyName("interval")] public long Interval { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs index 45fffa5a070..f55d20afab7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Rollup; public sealed partial class RollupCapabilitySummary { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary> Fields { get; init; } [JsonInclude, JsonPropertyName("index_pattern")] public string IndexPattern { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs index a015ca60a97..26a49395779 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Rollup; public sealed partial class RollupJobSummary { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary> Fields { get; init; } [JsonInclude, JsonPropertyName("index_pattern")] public string IndexPattern { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs index 5a0659a009a..6b293996e82 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs @@ -27,6 +27,45 @@ namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class TermsGroupingConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + + public override TermsGrouping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryReadProperty(ref reader, options, PropFields, static Elastic.Clients.Elasticsearch.Fields (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadValueEx(o, typeof(SingleOrManyFieldsMarker))!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsGrouping + { + Fields = propFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsGrouping value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Fields v) => w.WriteValueEx(o, v, typeof(SingleOrManyFieldsMarker))); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsGroupingConverter))] public sealed partial class TermsGrouping { /// @@ -36,8 +75,6 @@ public sealed partial class TermsGrouping /// Order does not matter. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs index 34346cfb0ce..b06fa7f078f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs @@ -27,6 +27,95 @@ namespace Elastic.Clients.Elasticsearch; +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); + LocalJsonValue?> propFilter = default; + LocalJsonValue propMatchCriteria = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propRankWindowSize = default; + LocalJsonValue propRetriever = default; + LocalJsonValue> propRulesetIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryReadProperty(ref reader, options, PropFilter, static ICollection? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadSingleOrManyCollectionValue(o, null))) + { + continue; + } + + if (propMatchCriteria.TryReadProperty(ref reader, options, PropMatchCriteria, null)) + { + continue; + } + + if (propMinScore.TryReadProperty(ref reader, options, PropMinScore, null)) + { + continue; + } + + if (propRankWindowSize.TryReadProperty(ref reader, options, PropRankWindowSize, null)) + { + continue; + } + + if (propRetriever.TryReadProperty(ref reader, options, PropRetriever, null)) + { + continue; + } + + if (propRulesetIds.TryReadProperty(ref reader, options, PropRulesetIds, static ICollection (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue(o, null)!)) + { + continue; + } + + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) + { + reader.Skip(); + } + + 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, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection? v) => w.WriteSingleOrManyCollectionValue(o, v, null)); + writer.WriteProperty(options, PropMatchCriteria, value.MatchCriteria, null, null); + writer.WriteProperty(options, PropMinScore, value.MinScore, null, null); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize, null, null); + writer.WriteProperty(options, PropRetriever, value.Retriever, null, null); + writer.WriteProperty(options, PropRulesetIds, value.RulesetIds, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, ICollection v) => w.WriteCollectionValue(o, v, null)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuleRetrieverConverter))] public sealed partial class RuleRetriever { /// @@ -34,8 +123,6 @@ public sealed partial class RuleRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +130,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 +137,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 +144,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 +151,6 @@ public sealed partial class RuleRetriever /// The retriever whose results rules should be applied to. /// /// - [JsonInclude, JsonPropertyName("retriever")] public Elastic.Clients.Elasticsearch.Retriever Retriever { get; set; } /// @@ -75,7 +158,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.Retriever(RuleRetriever ruleRetriever) => Elastic.Clients.Elasticsearch.Retriever.Rule(ruleRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs index bb90104b52e..481e53cf87f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs @@ -27,6 +27,91 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ScriptConverter : System.Text.Json.Serialization.JsonConverter