forked from elastic/elasticsearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndicesStatsDescriptor.cs
71 lines (60 loc) · 2.35 KB
/
IndicesStatsDescriptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using Elasticsearch.Net;
using Newtonsoft.Json;
namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public interface IIndicesStatsRequest : IIndicesOptionalPath<IndicesStatsRequestParameters>
{
IEnumerable<TypeNameMarker> Types { get; set; }
IEnumerable<IndicesStatsMetric> Metrics { get; set; }
}
internal static class IndicesStatsPathInfo
{
public static void Update(IConnectionSettingsValues settings, ElasticsearchPathInfo<IndicesStatsRequestParameters> pathInfo, IIndicesStatsRequest request)
{
if (request.Types.HasAny())
{
var inferrer = new ElasticInferrer(settings);
var types = inferrer.TypeNames(request.Types);
pathInfo.RequestParameters.AddQueryString("types", string.Join(",", types));
}
if (request.Metrics != null)
pathInfo.Metric = request.Metrics.Cast<Enum>().GetStringValue();
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
}
}
public partial class IndicesStatsRequest : IndicesOptionalPathBase<IndicesStatsRequestParameters>, IIndicesStatsRequest
{
public IEnumerable<IndicesStatsMetric> Metrics { get; set; }
public IEnumerable<TypeNameMarker> Types { get; set; }
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<IndicesStatsRequestParameters> pathInfo)
{
IndicesStatsPathInfo.Update(settings, pathInfo , this);
}
}
[DescriptorFor("IndicesStats")]
public partial class IndicesStatsDescriptor : IndicesOptionalPathDescriptor<IndicesStatsDescriptor, IndicesStatsRequestParameters>, IIndicesStatsRequest
{
private IIndicesStatsRequest Self { get { return this; } }
IEnumerable<TypeNameMarker> IIndicesStatsRequest.Types { get; set; }
IEnumerable<IndicesStatsMetric> IIndicesStatsRequest.Metrics { get; set; }
//<summary>A comma-separated list of fields for `completion` metric (supports wildcards)</summary>
public IndicesStatsDescriptor Types(params TypeNameMarker[] types)
{
Self.Types = types;
return this;
}
public IndicesStatsDescriptor Metrics(params IndicesStatsMetric[] metrics)
{
Self.Metrics = metrics;
return this;
}
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<IndicesStatsRequestParameters> pathInfo)
{
IndicesStatsPathInfo.Update(settings, pathInfo, this);
}
}
}