|
| 1 | +// Licensed to Elasticsearch B.V under one or more agreements. |
| 2 | +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
| 3 | +// See the LICENSE file in the project root for more information |
| 4 | + |
| 5 | +using System; |
| 6 | +using System.Linq.Expressions; |
| 7 | +using System.Runtime.Serialization; |
| 8 | +using Elasticsearch.Net.Utf8Json; |
| 9 | + |
| 10 | +namespace Nest |
| 11 | +{ |
| 12 | + [InterfaceDataContract] |
| 13 | + [ReadAs(typeof(VariableWidthHistogramAggregation))] |
| 14 | + public interface IVariableWidthHistogramAggregation : IBucketAggregation |
| 15 | + { |
| 16 | + /// <summary> |
| 17 | + /// The field to target. |
| 18 | + /// </summary> |
| 19 | + [DataMember(Name = "field")] |
| 20 | + Field Field { get; set; } |
| 21 | + |
| 22 | + [DataMember(Name = "buckets")] |
| 23 | + int? Buckets { get; set; } |
| 24 | + |
| 25 | + [DataMember(Name = "initial_buffer")] |
| 26 | + int? InitialBuffer { get; set; } |
| 27 | + |
| 28 | + [DataMember(Name = "shard_size")] |
| 29 | + int? ShardSize { get; set; } |
| 30 | + } |
| 31 | + |
| 32 | + public class VariableWidthHistogramAggregation : BucketAggregationBase, IVariableWidthHistogramAggregation |
| 33 | + { |
| 34 | + public VariableWidthHistogramAggregation(string name) : base(name) { } |
| 35 | + |
| 36 | + /// <inheritdoc /> |
| 37 | + public Field Field { get; set; } |
| 38 | + /// <inheritdoc /> |
| 39 | + public int? Buckets { get; set; } |
| 40 | + /// <inheritdoc /> |
| 41 | + public int? InitialBuffer { get; set; } |
| 42 | + /// <inheritdoc /> |
| 43 | + public int? ShardSize { get; set; } |
| 44 | + |
| 45 | + internal override void WrapInContainer(AggregationContainer c) => c.VariableWidthHistogram = this; |
| 46 | + } |
| 47 | + |
| 48 | + public class VariableWidthHistogramAggregationDescriptor<T> |
| 49 | + : BucketAggregationDescriptorBase<VariableWidthHistogramAggregationDescriptor<T>, IVariableWidthHistogramAggregation, T>, IVariableWidthHistogramAggregation |
| 50 | + where T : class |
| 51 | + { |
| 52 | + Field IVariableWidthHistogramAggregation.Field { get; set; } |
| 53 | + int? IVariableWidthHistogramAggregation.Buckets { get; set; } |
| 54 | + int? IVariableWidthHistogramAggregation.InitialBuffer { get; set; } |
| 55 | + int? IVariableWidthHistogramAggregation.ShardSize { get; set; } |
| 56 | + |
| 57 | + /// <inheritdoc cref="IVariableWidthHistogramAggregation.Field" /> |
| 58 | + public VariableWidthHistogramAggregationDescriptor<T> Field(Field field) => Assign(field, (a, v) => a.Field = v); |
| 59 | + |
| 60 | + /// <inheritdoc cref="IVariableWidthHistogramAggregation.Field" /> |
| 61 | + public VariableWidthHistogramAggregationDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> field) => Assign(field, (a, v) => a.Field = v); |
| 62 | + |
| 63 | + /// <inheritdoc cref="IVariableWidthHistogramAggregation.Buckets" /> |
| 64 | + public VariableWidthHistogramAggregationDescriptor<T> Buckets(int? buckets) => Assign(buckets, (a, v) => a.Buckets = v); |
| 65 | + |
| 66 | + /// <inheritdoc cref="IVariableWidthHistogramAggregation.InitialBuffer" /> |
| 67 | + public VariableWidthHistogramAggregationDescriptor<T> InitialBuffer(int? initialBuffer) => Assign(initialBuffer, (a, v) => a.InitialBuffer = v); |
| 68 | + |
| 69 | + /// <inheritdoc cref="IVariableWidthHistogramAggregation.ShardSize" /> |
| 70 | + public VariableWidthHistogramAggregationDescriptor<T> ShardSize(int? shardSize) => Assign(shardSize, (a, v) => a.ShardSize = v); |
| 71 | + } |
| 72 | +} |
0 commit comments