Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,330 changes: 2,165 additions & 2,165 deletions src/Elastic.Clients.Elasticsearch/_Generated/SpecReferences.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal static void ReadItem(ref System.Text.Json.Utf8JsonReader reader, System
"value_count" => reader.ReadValue<Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregate>(options, null),
"variable_width_histogram" => reader.ReadValue<Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregate>(options, null),
"weighted_avg" => reader.ReadValue<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate>(options, null),
_ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Aggregations.IAggregate)}'.")
_ => options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetReader<Elastic.Clients.Elasticsearch.Aggregations.IAggregate>(discriminator!, out var variantReader) ? variantReader(ref reader, options)! : new Elastic.Clients.Elasticsearch.Aggregations.UnknownAggregate(discriminator!, System.Text.Json.JsonElement.ParseValue(ref reader))
};
}

Expand Down Expand Up @@ -365,8 +365,24 @@ internal static void WriteItem(System.Text.Json.Utf8JsonWriter writer, System.Te
case Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate v:
writer.WriteProperty(options, key, v, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, string v) => w.WritePropertyName<string>(o, v), static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate v) => w.WritePropertyName<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate>(o, v));
break;
case Elastic.Clients.Elasticsearch.Aggregations.UnknownAggregate custom:
writer.WritePropertyName(options, key, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, string v) => w.WritePropertyName<string>(o, v));
custom.Content.WriteTo(writer);
break;
default:
throw new System.Text.Json.JsonException($"Variant '{0}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Aggregations.IAggregate)}'.");
if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetWriter<Elastic.Clients.Elasticsearch.Aggregations.IAggregate>(value.GetType(), out var variantWriter))
{
if (!string.Equals(value.Type, variantWriter.Discriminator, System.StringComparison.Ordinal))
{
throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' is registered for discriminator '{variantWriter.Discriminator}' but reports '{value.Type}' for type '{nameof(Elastic.Clients.Elasticsearch.Aggregations.IAggregate)}'.");
}

writer.WritePropertyName(options, variantWriter.Discriminator + '#' + name, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, string v) => w.WritePropertyName<string>(o, v));
variantWriter.Write(writer, value, options);
break;
}

throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' with discriminator '{value.Type}' is not registered. Call settings.Variants.Register<{nameof(Elastic.Clients.Elasticsearch.Aggregations.IAggregate)}, T>(\"{value.Type}\") at startup.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,18 @@ public override Elastic.Clients.Elasticsearch.Aggregations.Aggregation Read(ref
continue;
}

if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip)
variantType = reader.GetString()!;
reader.Read();
if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetContainerReader(typeof(Elastic.Clients.Elasticsearch.Aggregations.Aggregation), variantType!, out var variantReader))
{
reader.SafeSkip();
continue;
variant = variantReader(ref reader, options);
}
else
{
variant = System.Text.Json.JsonElement.ParseValue(ref reader);
}

throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'.");
continue;
}

reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject);
Expand Down Expand Up @@ -1036,7 +1041,31 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
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(Elastic.Clients.Elasticsearch.Aggregations.Aggregation)}'.");
if (value.Variant is null)
{
break;
}

if (value.Variant is System.Text.Json.JsonElement element)
{
writer.WritePropertyName(value.VariantType!);
element.WriteTo(writer);
break;
}

if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetContainerWriter(typeof(Elastic.Clients.Elasticsearch.Aggregations.Aggregation), value.Variant.GetType(), out var variantWriter))
{
if (!string.Equals(value.VariantType, variantWriter.Discriminator, System.StringComparison.Ordinal))
{
throw new System.Text.Json.JsonException($"Container variant of runtime type '{value.Variant.GetType().Name}' is registered for variant name '{variantWriter.Discriminator}' but reports '{value.VariantType}' for type '{nameof(Elastic.Clients.Elasticsearch.Aggregations.Aggregation)}'.");
}

writer.WritePropertyName(variantWriter.Discriminator);
variantWriter.Write(writer, value.Variant, options);
break;
}

throw new System.Text.Json.JsonException($"Container variant of runtime type '{value.Variant.GetType().Name}' for variant '{value.VariantType}' is not registered. Call settings.Variants.RegisterContainer<{nameof(Elastic.Clients.Elasticsearch.Aggregations.Aggregation)}, T>(\"{value.VariantType}\") at startup.");
}

writer.WriteProperty(options, PropAggregations, value.Aggregations, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, System.Collections.Generic.IDictionary<string, Elastic.Clients.Elasticsearch.Aggregations.Aggregation>? v) => w.WriteDictionaryValue<string, Elastic.Clients.Elasticsearch.Aggregations.Aggregation>(o, v, null, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ private void SetVariant<T>(string type, T? value)
VariantType = type;
Variant = value;
}

public string? VariantName { get => VariantType; }

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public T? GetCustomVariant<T>(string variantName)
{
return GetVariant<T>(variantName);
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public void SetCustomVariant<T>(string variantName, T? value)
{
SetVariant<T>(variantName, value);
}
}

public readonly partial struct AggregationDescriptor<TDocument>
Expand Down Expand Up @@ -1670,6 +1684,13 @@ public Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor<TDocumen
return this;
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor<TDocument> CustomVariant<T>(string variantName, T? value)
{
Instance.SetCustomVariant<T>(variantName, value);
return this;
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
internal static Elastic.Clients.Elasticsearch.Aggregations.Aggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor<TDocument>> action)
{
Expand Down Expand Up @@ -3472,6 +3493,13 @@ public Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor AddMeta(
return this;
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor CustomVariant<T>(string variantName, T? value)
{
Instance.SetCustomVariant<T>(variantName, value);
return this;
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
internal static Elastic.Clients.Elasticsearch.Aggregations.Aggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.AggregationDescriptor> action)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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 System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Aggregations;

public sealed partial class UnknownAggregate : Elastic.Clients.Elasticsearch.Aggregations.IAggregate
{
public string Type { get; }
public System.Text.Json.JsonElement Content { get; }

public UnknownAggregate(string type, System.Text.Json.JsonElement content)
{
if (type is null)
{
throw new System.ArgumentNullException(nameof(type));
}

if (content.ValueKind is not System.Text.Json.JsonValueKind.Object)
{
throw new System.ArgumentException($"Content must be a JSON object, but got '{content.ValueKind}'.", nameof(content));
}

Type = type;
Content = content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public override Elastic.Clients.Elasticsearch.Analysis.IAnalyzer Read(ref System
"thai" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.ThaiAnalyzer>(options, null),
"turkish" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.TurkishAnalyzer>(options, null),
"whitespace" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer>(options, null),
_ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.IAnalyzer)}'.")
_ => ReadCustomVariant(ref reader, options, discriminator!)
};
}

Expand Down Expand Up @@ -250,7 +250,34 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer)value, null);
break;
default:
throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.IAnalyzer)}'.");
if (value is Elastic.Clients.Elasticsearch.Analysis.UnknownAnalyzer custom)
{
writer.WriteValue(options, custom, null);
break;
}

if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetWriter<Elastic.Clients.Elasticsearch.Analysis.IAnalyzer>(value.GetType(), out var variantWriter))
{
if (!string.Equals(value.Type, variantWriter.Discriminator, System.StringComparison.Ordinal))
{
throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' is registered for discriminator '{variantWriter.Discriminator}' but reports '{value.Type}' for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.IAnalyzer)}'.");
}

variantWriter.Write(writer, value, options);
break;
}

throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' with discriminator '{value.Type}' is not registered. Call settings.Variants.Register<{nameof(Elastic.Clients.Elasticsearch.Analysis.IAnalyzer)}, T>(\"{value.Type}\") at startup.");
}
}

private static Elastic.Clients.Elasticsearch.Analysis.IAnalyzer ReadCustomVariant(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, string discriminator)
{
if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetReader<Elastic.Clients.Elasticsearch.Analysis.IAnalyzer>(discriminator, out var variantReader))
{
return variantReader(ref reader, options)!;
}

return reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.UnknownAnalyzer>(options)!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override Elastic.Clients.Elasticsearch.Analysis.ICharFilter Read(ref Syst
"kuromoji_iteration_mark" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.KuromojiIterationMarkCharFilter>(options, null),
"mapping" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.MappingCharFilter>(options, null),
"pattern_replace" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter>(options, null),
_ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ICharFilter)}'.")
_ => ReadCustomVariant(ref reader, options, discriminator!)
};
}

Expand All @@ -74,7 +74,34 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter)value, null);
break;
default:
throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ICharFilter)}'.");
if (value is Elastic.Clients.Elasticsearch.Analysis.UnknownCharFilter custom)
{
writer.WriteValue(options, custom, null);
break;
}

if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetWriter<Elastic.Clients.Elasticsearch.Analysis.ICharFilter>(value.GetType(), out var variantWriter))
{
if (!string.Equals(value.Type, variantWriter.Discriminator, System.StringComparison.Ordinal))
{
throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' is registered for discriminator '{variantWriter.Discriminator}' but reports '{value.Type}' for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ICharFilter)}'.");
}

variantWriter.Write(writer, value, options);
break;
}

throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' with discriminator '{value.Type}' is not registered. Call settings.Variants.Register<{nameof(Elastic.Clients.Elasticsearch.Analysis.ICharFilter)}, T>(\"{value.Type}\") at startup.");
}
}

private static Elastic.Clients.Elasticsearch.Analysis.ICharFilter ReadCustomVariant(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, string discriminator)
{
if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetReader<Elastic.Clients.Elasticsearch.Analysis.ICharFilter>(discriminator, out var variantReader))
{
return variantReader(ref reader, options)!;
}

return reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.UnknownCharFilter>(options)!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public override Elastic.Clients.Elasticsearch.Analysis.ITokenFilter Read(ref Sys
"uppercase" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.UppercaseTokenFilter>(options, null),
"word_delimiter" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.WordDelimiterTokenFilter>(options, null),
"word_delimiter_graph" => reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter>(options, null),
_ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ITokenFilter)}'.")
_ => ReadCustomVariant(ref reader, options, discriminator!)
};
}

Expand Down Expand Up @@ -350,7 +350,34 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter)value, null);
break;
default:
throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ITokenFilter)}'.");
if (value is Elastic.Clients.Elasticsearch.Analysis.UnknownTokenFilter custom)
{
writer.WriteValue(options, custom, null);
break;
}

if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetWriter<Elastic.Clients.Elasticsearch.Analysis.ITokenFilter>(value.GetType(), out var variantWriter))
{
if (!string.Equals(value.Type, variantWriter.Discriminator, System.StringComparison.Ordinal))
{
throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' is registered for discriminator '{variantWriter.Discriminator}' but reports '{value.Type}' for type '{nameof(Elastic.Clients.Elasticsearch.Analysis.ITokenFilter)}'.");
}

variantWriter.Write(writer, value, options);
break;
}

throw new System.Text.Json.JsonException($"Variant of runtime type '{value.GetType().Name}' with discriminator '{value.Type}' is not registered. Call settings.Variants.Register<{nameof(Elastic.Clients.Elasticsearch.Analysis.ITokenFilter)}, T>(\"{value.Type}\") at startup.");
}
}

private static Elastic.Clients.Elasticsearch.Analysis.ITokenFilter ReadCustomVariant(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, string discriminator)
{
if (options.TryGetContext<Elastic.Clients.Elasticsearch.IElasticsearchClientSettings>(out var settings) && settings.Variants.TryGetReader<Elastic.Clients.Elasticsearch.Analysis.ITokenFilter>(discriminator, out var variantReader))
{
return variantReader(ref reader, options)!;
}

return reader.ReadValue<Elastic.Clients.Elasticsearch.Analysis.UnknownTokenFilter>(options)!;
}
}
Loading
Loading