Skip to content

Commit c8ac001

Browse files
committed
Regenerate
1 parent 7a28d15 commit c8ac001

8 files changed

+190
-703
lines changed

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregationRange.g.cs

Lines changed: 124 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,107 +23,166 @@
2323

2424
namespace Elastic.Clients.Elasticsearch.Aggregations;
2525

26-
internal sealed partial class IAggregationRangeConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange>
26+
internal sealed partial class AggregationRangeConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Aggregations.AggregationRange>
2727
{
28-
public override Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
29-
{
30-
return reader.ReadValue<Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRange>(options, null);
31-
}
28+
private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from");
29+
private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key");
30+
private static readonly System.Text.Json.JsonEncodedText PropTo = System.Text.Json.JsonEncodedText.Encode("to");
3231

33-
public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange value, System.Text.Json.JsonSerializerOptions options)
32+
public override Elastic.Clients.Elasticsearch.Aggregations.AggregationRange Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
3433
{
35-
switch (value)
34+
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
35+
LocalJsonValue<double?> propFrom = default;
36+
LocalJsonValue<string?> propKey = default;
37+
LocalJsonValue<double?> propTo = default;
38+
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
3639
{
37-
case Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange v:
38-
writer.WriteValue(options, v, null);
39-
break;
40-
case Elastic.Clients.Elasticsearch.Aggregations.NumberAggregationRange v:
41-
writer.WriteValue(options, v, null);
42-
break;
43-
case Elastic.Clients.Elasticsearch.Aggregations.TermAggregationRange v:
44-
writer.WriteValue(options, v, null);
45-
break;
46-
case Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRange v:
47-
writer.WriteValue(options, v, null);
48-
break;
49-
default:
50-
throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange)}'.");
40+
if (propFrom.TryReadProperty(ref reader, options, PropFrom, null))
41+
{
42+
continue;
43+
}
44+
45+
if (propKey.TryReadProperty(ref reader, options, PropKey, null))
46+
{
47+
continue;
48+
}
49+
50+
if (propTo.TryReadProperty(ref reader, options, PropTo, null))
51+
{
52+
continue;
53+
}
54+
55+
if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip)
56+
{
57+
reader.Skip();
58+
continue;
59+
}
60+
61+
throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'.");
5162
}
52-
}
53-
}
54-
55-
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.IAggregationRangeConverter))]
56-
public partial interface IAggregationRange
57-
{
58-
public string Type { get; }
59-
}
6063

61-
public readonly partial struct IAggregationRangeFactory
62-
{
63-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Date(Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange value)
64-
{
65-
return value;
64+
reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject);
65+
return new Elastic.Clients.Elasticsearch.Aggregations.AggregationRange(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance)
66+
{
67+
From = propFrom.Value,
68+
Key = propKey.Value,
69+
To = propTo.Value
70+
};
6671
}
6772

68-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Date()
73+
public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Aggregations.AggregationRange value, System.Text.Json.JsonSerializerOptions options)
6974
{
70-
return Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor.Build(null);
75+
writer.WriteStartObject();
76+
writer.WriteProperty(options, PropFrom, value.From, null, null);
77+
writer.WriteProperty(options, PropKey, value.Key, null, null);
78+
writer.WriteProperty(options, PropTo, value.To, null, null);
79+
writer.WriteEndObject();
7180
}
81+
}
7282

73-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Date(System.Action<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor>? action)
83+
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeConverter))]
84+
public sealed partial class AggregationRange
85+
{
86+
#if NET7_0_OR_GREATER
87+
public AggregationRange()
7488
{
75-
return Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor.Build(action);
7689
}
77-
78-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Number(Elastic.Clients.Elasticsearch.Aggregations.NumberAggregationRange value)
90+
#endif
91+
#if !NET7_0_OR_GREATER
92+
public AggregationRange()
7993
{
80-
return value;
8194
}
82-
83-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Number()
95+
#endif
96+
[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
97+
internal AggregationRange(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
8498
{
85-
return Elastic.Clients.Elasticsearch.Aggregations.NumberAggregationRangeDescriptor.Build(null);
99+
_ = sentinel;
86100
}
87101

88-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Number(System.Action<Elastic.Clients.Elasticsearch.Aggregations.NumberAggregationRangeDescriptor>? action)
89-
{
90-
return Elastic.Clients.Elasticsearch.Aggregations.NumberAggregationRangeDescriptor.Build(action);
91-
}
102+
/// <summary>
103+
/// <para>
104+
/// Start of the range (inclusive).
105+
/// </para>
106+
/// </summary>
107+
public double? From { get; set; }
108+
109+
/// <summary>
110+
/// <para>
111+
/// Custom key to return the range with.
112+
/// </para>
113+
/// </summary>
114+
public string? Key { get; set; }
115+
116+
/// <summary>
117+
/// <para>
118+
/// End of the range (exclusive).
119+
/// </para>
120+
/// </summary>
121+
public double? To { get; set; }
122+
}
92123

93-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Term(Elastic.Clients.Elasticsearch.Aggregations.TermAggregationRange value)
94-
{
95-
return value;
96-
}
124+
public readonly partial struct AggregationRangeDescriptor
125+
{
126+
internal Elastic.Clients.Elasticsearch.Aggregations.AggregationRange Instance { get; init; }
97127

98-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Term()
128+
[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
129+
public AggregationRangeDescriptor(Elastic.Clients.Elasticsearch.Aggregations.AggregationRange instance)
99130
{
100-
return Elastic.Clients.Elasticsearch.Aggregations.TermAggregationRangeDescriptor.Build(null);
131+
Instance = instance;
101132
}
102133

103-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Term(System.Action<Elastic.Clients.Elasticsearch.Aggregations.TermAggregationRangeDescriptor>? action)
134+
[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
135+
public AggregationRangeDescriptor()
104136
{
105-
return Elastic.Clients.Elasticsearch.Aggregations.TermAggregationRangeDescriptor.Build(action);
137+
Instance = new Elastic.Clients.Elasticsearch.Aggregations.AggregationRange(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
106138
}
107139

108-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Untyped(Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRange value)
140+
public static explicit operator Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor(Elastic.Clients.Elasticsearch.Aggregations.AggregationRange instance) => new Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor(instance);
141+
public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.AggregationRange(Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor descriptor) => descriptor.Instance;
142+
143+
/// <summary>
144+
/// <para>
145+
/// Start of the range (inclusive).
146+
/// </para>
147+
/// </summary>
148+
public Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor From(double? value)
109149
{
110-
return value;
150+
Instance.From = value;
151+
return this;
111152
}
112153

113-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Untyped()
154+
/// <summary>
155+
/// <para>
156+
/// Custom key to return the range with.
157+
/// </para>
158+
/// </summary>
159+
public Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor Key(string? value)
114160
{
115-
return Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRangeDescriptor.Build(null);
161+
Instance.Key = value;
162+
return this;
116163
}
117164

118-
public Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Untyped(System.Action<Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRangeDescriptor>? action)
165+
/// <summary>
166+
/// <para>
167+
/// End of the range (exclusive).
168+
/// </para>
169+
/// </summary>
170+
public Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor To(double? value)
119171
{
120-
return Elastic.Clients.Elasticsearch.Aggregations.UntypedAggregationRangeDescriptor.Build(action);
172+
Instance.To = value;
173+
return this;
121174
}
122175

123176
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
124-
internal static Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange Build(System.Func<Elastic.Clients.Elasticsearch.Aggregations.IAggregationRangeFactory, Elastic.Clients.Elasticsearch.Aggregations.IAggregationRange> action)
177+
internal static Elastic.Clients.Elasticsearch.Aggregations.AggregationRange Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor>? action)
125178
{
126-
var builder = new Elastic.Clients.Elasticsearch.Aggregations.IAggregationRangeFactory();
127-
return action.Invoke(builder);
179+
if (action is null)
180+
{
181+
return new Elastic.Clients.Elasticsearch.Aggregations.AggregationRange(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
182+
}
183+
184+
var builder = new Elastic.Clients.Elasticsearch.Aggregations.AggregationRangeDescriptor(new Elastic.Clients.Elasticsearch.Aggregations.AggregationRange(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
185+
action.Invoke(builder);
186+
return builder.Instance;
128187
}
129188
}

src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation
3737
LocalJsonValue<Elastic.Clients.Elasticsearch.Field?> propField = default;
3838
LocalJsonValue<string?> propFormat = default;
3939
LocalJsonValue<object?> propMissing = default;
40-
LocalJsonValue<System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>?> propRanges = default;
40+
LocalJsonValue<System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>?> propRanges = default;
4141
LocalJsonValue<string?> propTimeZone = default;
4242
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
4343
{
@@ -56,7 +56,7 @@ public override Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation
5656
continue;
5757
}
5858

59-
if (propRanges.TryReadProperty(ref reader, options, PropRanges, static System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>(o, null)))
59+
if (propRanges.TryReadProperty(ref reader, options, PropRanges, static System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadCollectionValue<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>(o, null)))
6060
{
6161
continue;
6262
}
@@ -92,7 +92,7 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
9292
writer.WriteProperty(options, PropField, value.Field, null, null);
9393
writer.WriteProperty(options, PropFormat, value.Format, null, null);
9494
writer.WriteProperty(options, PropMissing, value.Missing, null, null);
95-
writer.WriteProperty(options, PropRanges, value.Ranges, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>? v) => w.WriteCollectionValue<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>(o, v, null));
95+
writer.WriteProperty(options, PropRanges, value.Ranges, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? v) => w.WriteCollectionValue<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>(o, v, null));
9696
writer.WriteProperty(options, PropTimeZone, value.TimeZone, null, null);
9797
writer.WriteEndObject();
9898
}
@@ -144,7 +144,7 @@ internal DateRangeAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonCo
144144
/// Array of date ranges.
145145
/// </para>
146146
/// </summary>
147-
public System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>? Ranges { get; set; }
147+
public System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? Ranges { get; set; }
148148

149149
/// <summary>
150150
/// <para>
@@ -223,7 +223,7 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
223223
/// Array of date ranges.
224224
/// </para>
225225
/// </summary>
226-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>? value)
226+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? value)
227227
{
228228
Instance.Ranges = value;
229229
return this;
@@ -234,7 +234,7 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
234234
/// Array of date ranges.
235235
/// </para>
236236
/// </summary>
237-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(params Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange[] values)
237+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(params Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression[] values)
238238
{
239239
Instance.Ranges = [.. values];
240240
return this;
@@ -245,12 +245,12 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
245245
/// Array of date ranges.
246246
/// </para>
247247
/// </summary>
248-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(params System.Action<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor>?[] actions)
248+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor<TDocument> Ranges(params System.Action<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpressionDescriptor>?[] actions)
249249
{
250-
var items = new System.Collections.Generic.List<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>();
250+
var items = new System.Collections.Generic.List<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>();
251251
foreach (var action in actions)
252252
{
253-
items.Add(Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor.Build(action));
253+
items.Add(Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpressionDescriptor.Build(action));
254254
}
255255

256256
Instance.Ranges = items;
@@ -351,7 +351,7 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
351351
/// Array of date ranges.
352352
/// </para>
353353
/// </summary>
354-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>? value)
354+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? value)
355355
{
356356
Instance.Ranges = value;
357357
return this;
@@ -362,7 +362,7 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
362362
/// Array of date ranges.
363363
/// </para>
364364
/// </summary>
365-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(params Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange[] values)
365+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(params Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression[] values)
366366
{
367367
Instance.Ranges = [.. values];
368368
return this;
@@ -373,12 +373,12 @@ public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor
373373
/// Array of date ranges.
374374
/// </para>
375375
/// </summary>
376-
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(params System.Action<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor>?[] actions)
376+
public Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregationDescriptor Ranges(params System.Action<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpressionDescriptor>?[] actions)
377377
{
378-
var items = new System.Collections.Generic.List<Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRange>();
378+
var items = new System.Collections.Generic.List<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>();
379379
foreach (var action in actions)
380380
{
381-
items.Add(Elastic.Clients.Elasticsearch.Aggregations.DateAggregationRangeDescriptor.Build(action));
381+
items.Add(Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpressionDescriptor.Build(action));
382382
}
383383

384384
Instance.Ranges = items;

0 commit comments

Comments
 (0)