Skip to content

Commit 28f6a5e

Browse files
authored
Updates Indices Stats and Node Stats to remove obsolete enum value (#3880)
Updates Indices Stats and Node Stats to remove obsolete enum value and add additional values.
1 parent 7a5f620 commit 28f6a5e

File tree

7 files changed

+143
-120
lines changed

7 files changed

+143
-120
lines changed

src/CodeGeneration/ApiGenerator/Configuration/Overrides/GlobalOverrides.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@ namespace ApiGenerator.Configuration.Overrides
44
{
55
public class GlobalOverrides : EndpointOverridesBase
66
{
7-
public IDictionary<string, Dictionary<string, string>> ObsoleteEnumMembers { get; set; } = new Dictionary<string, Dictionary<string, string>>
8-
{
9-
{
10-
"NodesStatsIndexMetric",
11-
new Dictionary<string, string> { { "suggest", "As of 5.0 this option always returned an empty object in the response" } }
12-
},
13-
{
14-
"IndicesStatsMetric",
15-
new Dictionary<string, string> { { "suggest", "Suggest stats have folded under the search stats, this alias will be removed" } }
16-
}
17-
};
7+
public IDictionary<string, Dictionary<string, string>> ObsoleteEnumMembers { get; set; } = new Dictionary<string, Dictionary<string, string>>();
188

199
public override IDictionary<string, string> ObsoleteQueryStringParams { get; set; } = new Dictionary<string, string>
2010
{

src/CodeGeneration/ApiGenerator/Generator/ApiEndpointFactory.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@ private static void PatchOfficialSpec(JObject original, string jsonFile)
9191
});
9292

9393
if (pathsOverride != null) original.SelectToken("*.url.paths").Replace(pathsOverride);
94-
}
9594

95+
void ReplaceOptions(string path)
96+
{
97+
var optionsOverrides = patchedJson.SelectToken(path);
98+
if (optionsOverrides != null)
99+
original.SelectToken(path).Replace(optionsOverrides);
100+
}
101+
102+
ReplaceOptions("*.url.parts.metric.options");
103+
ReplaceOptions("*.url.parts.index_metric.options");
104+
}
96105
}
97-
}
106+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"indices.stats": {
3+
"url": {
4+
"parts": {
5+
"metric" : {
6+
"options": [ "_all", "store", "indexing", "get", "search", "merge", "flush", "refresh", "query_cache", "fielddata", "docs", "warmer", "completion", "segments", "translog", "request_cache", "recovery" ]
7+
}
8+
}
9+
}
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"nodes.stats": {
3+
"url": {
4+
"parts": {
5+
"index_metric" : {
6+
"options": [ "_all", "store", "indexing", "get", "search", "merge", "flush", "refresh", "query_cache", "fielddata", "docs", "warmer", "completion", "segments", "translog", "request_cache", "recovery" ]
7+
}
8+
}
9+
}
10+
}
11+
}

src/Elasticsearch.Net/Api/Enums.Generated.cs

Lines changed: 106 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,40 @@ public enum ClusterStateMetric
4949
[Flags, StringEnum]
5050
public enum IndicesStatsMetric
5151
{
52-
[EnumMember(Value = "completion")]
53-
Completion = 1 << 0,
54-
[EnumMember(Value = "docs")]
55-
Docs = 1 << 1,
56-
[EnumMember(Value = "fielddata")]
57-
Fielddata = 1 << 2,
58-
[EnumMember(Value = "query_cache")]
59-
QueryCache = 1 << 3,
60-
[EnumMember(Value = "flush")]
61-
Flush = 1 << 4,
62-
[EnumMember(Value = "get")]
63-
Get = 1 << 5,
52+
[EnumMember(Value = "store")]
53+
Store = 1 << 0,
6454
[EnumMember(Value = "indexing")]
65-
Indexing = 1 << 6,
55+
Indexing = 1 << 1,
56+
[EnumMember(Value = "get")]
57+
Get = 1 << 2,
58+
[EnumMember(Value = "search")]
59+
Search = 1 << 3,
6660
[EnumMember(Value = "merge")]
67-
Merge = 1 << 7,
68-
[EnumMember(Value = "request_cache")]
69-
RequestCache = 1 << 8,
61+
Merge = 1 << 4,
62+
[EnumMember(Value = "flush")]
63+
Flush = 1 << 5,
7064
[EnumMember(Value = "refresh")]
71-
Refresh = 1 << 9,
72-
[EnumMember(Value = "search")]
73-
Search = 1 << 10,
74-
[EnumMember(Value = "segments")]
75-
Segments = 1 << 11,
76-
[EnumMember(Value = "store")]
77-
Store = 1 << 12,
65+
Refresh = 1 << 6,
66+
[EnumMember(Value = "query_cache")]
67+
QueryCache = 1 << 7,
68+
[EnumMember(Value = "fielddata")]
69+
Fielddata = 1 << 8,
70+
[EnumMember(Value = "docs")]
71+
Docs = 1 << 9,
7872
[EnumMember(Value = "warmer")]
79-
Warmer = 1 << 13,
80-
[Obsolete("Suggest stats have folded under the search stats, this alias will be removed")]
81-
[EnumMember(Value = "suggest")]
82-
Suggest = 1 << 14,
73+
Warmer = 1 << 10,
74+
[EnumMember(Value = "completion")]
75+
Completion = 1 << 11,
76+
[EnumMember(Value = "segments")]
77+
Segments = 1 << 12,
78+
[EnumMember(Value = "translog")]
79+
Translog = 1 << 13,
80+
[EnumMember(Value = "request_cache")]
81+
RequestCache = 1 << 14,
82+
[EnumMember(Value = "recovery")]
83+
Recovery = 1 << 15,
8384
[EnumMember(Value = "_all")]
84-
All = 1 << 15
85+
All = 1 << 16
8586
}
8687

8788
[Flags, StringEnum]
@@ -137,39 +138,40 @@ public enum NodesStatsMetric
137138
[Flags, StringEnum]
138139
public enum NodesStatsIndexMetric
139140
{
140-
[EnumMember(Value = "completion")]
141-
Completion = 1 << 0,
142-
[EnumMember(Value = "docs")]
143-
Docs = 1 << 1,
144-
[EnumMember(Value = "fielddata")]
145-
Fielddata = 1 << 2,
146-
[EnumMember(Value = "query_cache")]
147-
QueryCache = 1 << 3,
148-
[EnumMember(Value = "flush")]
149-
Flush = 1 << 4,
150-
[EnumMember(Value = "get")]
151-
Get = 1 << 5,
141+
[EnumMember(Value = "store")]
142+
Store = 1 << 0,
152143
[EnumMember(Value = "indexing")]
153-
Indexing = 1 << 6,
144+
Indexing = 1 << 1,
145+
[EnumMember(Value = "get")]
146+
Get = 1 << 2,
147+
[EnumMember(Value = "search")]
148+
Search = 1 << 3,
154149
[EnumMember(Value = "merge")]
155-
Merge = 1 << 7,
156-
[EnumMember(Value = "request_cache")]
157-
RequestCache = 1 << 8,
150+
Merge = 1 << 4,
151+
[EnumMember(Value = "flush")]
152+
Flush = 1 << 5,
158153
[EnumMember(Value = "refresh")]
159-
Refresh = 1 << 9,
160-
[EnumMember(Value = "search")]
161-
Search = 1 << 10,
162-
[EnumMember(Value = "segments")]
163-
Segments = 1 << 11,
164-
[EnumMember(Value = "store")]
165-
Store = 1 << 12,
154+
Refresh = 1 << 6,
155+
[EnumMember(Value = "query_cache")]
156+
QueryCache = 1 << 7,
157+
[EnumMember(Value = "fielddata")]
158+
Fielddata = 1 << 8,
159+
[EnumMember(Value = "docs")]
160+
Docs = 1 << 9,
166161
[EnumMember(Value = "warmer")]
167-
Warmer = 1 << 13,
168-
[Obsolete("As of 5.0 this option always returned an empty object in the response")]
169-
[EnumMember(Value = "suggest")]
170-
Suggest = 1 << 14,
162+
Warmer = 1 << 10,
163+
[EnumMember(Value = "completion")]
164+
Completion = 1 << 11,
165+
[EnumMember(Value = "segments")]
166+
Segments = 1 << 12,
167+
[EnumMember(Value = "translog")]
168+
Translog = 1 << 13,
169+
[EnumMember(Value = "request_cache")]
170+
RequestCache = 1 << 14,
171+
[EnumMember(Value = "recovery")]
172+
Recovery = 1 << 15,
171173
[EnumMember(Value = "_all")]
172-
All = 1 << 15
174+
All = 1 << 16
173175
}
174176

175177
[Flags, StringEnum]
@@ -498,38 +500,38 @@ public static string GetStringValue(this IndicesStatsMetric enumValue)
498500
if ((enumValue & IndicesStatsMetric.All) != 0)
499501
return "_all";
500502
var list = new List<string>();
501-
if ((enumValue & IndicesStatsMetric.Completion) != 0)
502-
list.Add("completion");
503-
if ((enumValue & IndicesStatsMetric.Docs) != 0)
504-
list.Add("docs");
505-
if ((enumValue & IndicesStatsMetric.Fielddata) != 0)
506-
list.Add("fielddata");
507-
if ((enumValue & IndicesStatsMetric.QueryCache) != 0)
508-
list.Add("query_cache");
509-
if ((enumValue & IndicesStatsMetric.Flush) != 0)
510-
list.Add("flush");
511-
if ((enumValue & IndicesStatsMetric.Get) != 0)
512-
list.Add("get");
503+
if ((enumValue & IndicesStatsMetric.Store) != 0)
504+
list.Add("store");
513505
if ((enumValue & IndicesStatsMetric.Indexing) != 0)
514506
list.Add("indexing");
507+
if ((enumValue & IndicesStatsMetric.Get) != 0)
508+
list.Add("get");
509+
if ((enumValue & IndicesStatsMetric.Search) != 0)
510+
list.Add("search");
515511
if ((enumValue & IndicesStatsMetric.Merge) != 0)
516512
list.Add("merge");
517-
if ((enumValue & IndicesStatsMetric.RequestCache) != 0)
518-
list.Add("request_cache");
513+
if ((enumValue & IndicesStatsMetric.Flush) != 0)
514+
list.Add("flush");
519515
if ((enumValue & IndicesStatsMetric.Refresh) != 0)
520516
list.Add("refresh");
521-
if ((enumValue & IndicesStatsMetric.Search) != 0)
522-
list.Add("search");
523-
if ((enumValue & IndicesStatsMetric.Segments) != 0)
524-
list.Add("segments");
525-
if ((enumValue & IndicesStatsMetric.Store) != 0)
526-
list.Add("store");
517+
if ((enumValue & IndicesStatsMetric.QueryCache) != 0)
518+
list.Add("query_cache");
519+
if ((enumValue & IndicesStatsMetric.Fielddata) != 0)
520+
list.Add("fielddata");
521+
if ((enumValue & IndicesStatsMetric.Docs) != 0)
522+
list.Add("docs");
527523
if ((enumValue & IndicesStatsMetric.Warmer) != 0)
528524
list.Add("warmer");
529-
#pragma warning disable 618
530-
if ((enumValue & IndicesStatsMetric.Suggest) != 0)
531-
list.Add("suggest");
532-
#pragma warning restore 618
525+
if ((enumValue & IndicesStatsMetric.Completion) != 0)
526+
list.Add("completion");
527+
if ((enumValue & IndicesStatsMetric.Segments) != 0)
528+
list.Add("segments");
529+
if ((enumValue & IndicesStatsMetric.Translog) != 0)
530+
list.Add("translog");
531+
if ((enumValue & IndicesStatsMetric.RequestCache) != 0)
532+
list.Add("request_cache");
533+
if ((enumValue & IndicesStatsMetric.Recovery) != 0)
534+
list.Add("recovery");
533535
return string.Join(",", list);
534536
}
535537

@@ -590,38 +592,38 @@ public static string GetStringValue(this NodesStatsIndexMetric enumValue)
590592
if ((enumValue & NodesStatsIndexMetric.All) != 0)
591593
return "_all";
592594
var list = new List<string>();
593-
if ((enumValue & NodesStatsIndexMetric.Completion) != 0)
594-
list.Add("completion");
595-
if ((enumValue & NodesStatsIndexMetric.Docs) != 0)
596-
list.Add("docs");
597-
if ((enumValue & NodesStatsIndexMetric.Fielddata) != 0)
598-
list.Add("fielddata");
599-
if ((enumValue & NodesStatsIndexMetric.QueryCache) != 0)
600-
list.Add("query_cache");
601-
if ((enumValue & NodesStatsIndexMetric.Flush) != 0)
602-
list.Add("flush");
603-
if ((enumValue & NodesStatsIndexMetric.Get) != 0)
604-
list.Add("get");
595+
if ((enumValue & NodesStatsIndexMetric.Store) != 0)
596+
list.Add("store");
605597
if ((enumValue & NodesStatsIndexMetric.Indexing) != 0)
606598
list.Add("indexing");
599+
if ((enumValue & NodesStatsIndexMetric.Get) != 0)
600+
list.Add("get");
601+
if ((enumValue & NodesStatsIndexMetric.Search) != 0)
602+
list.Add("search");
607603
if ((enumValue & NodesStatsIndexMetric.Merge) != 0)
608604
list.Add("merge");
609-
if ((enumValue & NodesStatsIndexMetric.RequestCache) != 0)
610-
list.Add("request_cache");
605+
if ((enumValue & NodesStatsIndexMetric.Flush) != 0)
606+
list.Add("flush");
611607
if ((enumValue & NodesStatsIndexMetric.Refresh) != 0)
612608
list.Add("refresh");
613-
if ((enumValue & NodesStatsIndexMetric.Search) != 0)
614-
list.Add("search");
615-
if ((enumValue & NodesStatsIndexMetric.Segments) != 0)
616-
list.Add("segments");
617-
if ((enumValue & NodesStatsIndexMetric.Store) != 0)
618-
list.Add("store");
609+
if ((enumValue & NodesStatsIndexMetric.QueryCache) != 0)
610+
list.Add("query_cache");
611+
if ((enumValue & NodesStatsIndexMetric.Fielddata) != 0)
612+
list.Add("fielddata");
613+
if ((enumValue & NodesStatsIndexMetric.Docs) != 0)
614+
list.Add("docs");
619615
if ((enumValue & NodesStatsIndexMetric.Warmer) != 0)
620616
list.Add("warmer");
621-
#pragma warning disable 618
622-
if ((enumValue & NodesStatsIndexMetric.Suggest) != 0)
623-
list.Add("suggest");
624-
#pragma warning restore 618
617+
if ((enumValue & NodesStatsIndexMetric.Completion) != 0)
618+
list.Add("completion");
619+
if ((enumValue & NodesStatsIndexMetric.Segments) != 0)
620+
list.Add("segments");
621+
if ((enumValue & NodesStatsIndexMetric.Translog) != 0)
622+
list.Add("translog");
623+
if ((enumValue & NodesStatsIndexMetric.RequestCache) != 0)
624+
list.Add("request_cache");
625+
if ((enumValue & NodesStatsIndexMetric.Recovery) != 0)
626+
list.Add("recovery");
625627
return string.Join(",", list);
626628
}
627629

src/Tests/Tests/Cluster/NodesStats/NodesStatsUrlTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ await GET("/_nodes/foo/stats/fs%2Cjvm")
4141
;
4242

4343
var indexMetrics = NodesStatsIndexMetric.Fielddata | NodesStatsIndexMetric.Merge;
44-
await GET("/_nodes/stats/fs%2Cjvm/fielddata%2Cmerge")
44+
await GET("/_nodes/stats/fs%2Cjvm/merge%2Cfielddata")
4545
.Fluent(c => c.Nodes.Stats(p => p.Metric(metrics).IndexMetric(indexMetrics)))
4646
.Request(c => c.Nodes.Stats(new NodesStatsRequest(metrics, indexMetrics)))
4747
.FluentAsync(c => c.Nodes.StatsAsync(p => p.Metric(metrics).IndexMetric(indexMetrics)))
4848
.RequestAsync(c => c.Nodes.StatsAsync(new NodesStatsRequest(metrics, indexMetrics)))
4949
;
5050

51-
await GET("/_nodes/foo/stats/fs%2Cjvm/fielddata%2Cmerge")
51+
await GET("/_nodes/foo/stats/fs%2Cjvm/merge%2Cfielddata")
5252
.Fluent(c => c.Nodes.Stats(p => p.NodeId("foo").Metric(metrics).IndexMetric(indexMetrics)))
5353
.Request(c => c.Nodes.Stats(new NodesStatsRequest("foo", metrics, indexMetrics)))
5454
.FluentAsync(c => c.Nodes.StatsAsync(p => p.NodeId("foo").Metric(metrics).IndexMetric(indexMetrics)))

src/Tests/Tests/Indices/Monitoring/IndicesStats/IndicesStatsUrlTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ await GET($"/index1%2Cindex2/_stats")
3232
;
3333

3434
var metrics = IndicesStatsMetric.Completion | IndicesStatsMetric.Flush;
35-
await GET($"/index1%2Cindex2/_stats/completion%2Cflush")
35+
await GET($"/index1%2Cindex2/_stats/flush%2Ccompletion")
3636
.Fluent(c => c.Indices.Stats(index, i => i.Metric(metrics)))
3737
.Request(c => c.Indices.Stats(new IndicesStatsRequest(index, metrics)))
3838
.FluentAsync(c => c.Indices.StatsAsync(index, i => i.Metric(metrics)))

0 commit comments

Comments
 (0)