Skip to content

Commit 8c3eb48

Browse files
authored
Update master low level client to latest APIs (#4571)
Update master low level client to latest APIs
1 parent 57909cf commit 8c3eb48

File tree

233 files changed

+3093
-1610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+3093
-1610
lines changed

src/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 86 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,21 @@ public static class CodeConfiguration
7373
};
7474

7575

76+
/// <summary>
77+
/// Map API default names for API's we are only supporting on the low level client first
78+
/// </summary>
79+
private static readonly Dictionary<string, string> LowLevelApiNameMapping = new Dictionary<string, string>
80+
{
81+
{ "indices.delete_index_template", "DeleteIndexTemplateV2" },
82+
{ "indices.get_index_template", "GetIndexTemplateV2" },
83+
{ "indices.put_index_template", "PutIndexTemplateV2" }
84+
};
85+
7686
/// <summary>
7787
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
7888
/// The class name minus Request is used as the canonical .NET name for the API.
7989
/// </summary>
80-
public static readonly Dictionary<string, string> ApiNameMapping =
90+
private static readonly Dictionary<string, string> HighLevelApiNameMapping =
8191
(from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*.cs", SearchOption.AllDirectories)
8292
let contents = File.ReadAllText(f.FullName)
8393
let c = Regex.Replace(contents, @"^.+\[MapsApi\(""([^ \r\n]+)""\)\].*$", "$1", RegexOptions.Singleline)
@@ -86,7 +96,28 @@ public static class CodeConfiguration
8696
.DistinctBy(v => v.Key)
8797
.ToDictionary(k => k.Key, v => v.Value.Replace(".cs", ""));
8898

99+
private static Dictionary<string, string> _apiNameMapping;
100+
101+
public static Dictionary<string, string> ApiNameMapping
102+
{
103+
get
104+
{
105+
if (_apiNameMapping != null) return _apiNameMapping;
106+
lock (LowLevelApiNameMapping)
107+
{
108+
if (_apiNameMapping != null) return _apiNameMapping;
109+
110+
var mapping = HighLevelApiNameMapping;
111+
foreach (var (k, v) in LowLevelApiNameMapping)
112+
mapping[k] = v;
113+
_apiNameMapping = mapping;
114+
return _apiNameMapping;
115+
}
116+
}
117+
}
118+
89119
private static readonly string ResponseBuilderAttributeRegex = @"^.+\[ResponseBuilderWithGeneric\(""([^ \r\n]+)""\)\].*$";
120+
90121
/// <summary>
91122
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
92123
/// The class name minus Request is used as the canonical .NET name for the API.
@@ -113,19 +144,19 @@ where Regex.IsMatch(l, ResponseBuilderAttributeRegex)
113144

114145
/// <summary> Scan all NEST files for request interfaces and note any generics declared on them </summary>
115146
private static readonly List<Tuple<string, string>> AllKnownRequestInterfaces = (
116-
// find all files in NEST ending with Request.cs
117-
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
118-
from l in File.ReadLines(f.FullName)
119-
// attempt to locate all Request interfaces lines
120-
where Regex.IsMatch(l, @"^.+interface [^ \r\n]+Request")
121-
//grab the interface name including any generics declared on it
122-
let c = Regex.Replace(l, @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
123-
where c.StartsWith("I") && c.Contains("Request")
124-
let request = Regex.Replace(c, "<.*$", "")
125-
let generics = Regex.Replace(c, @"^.*?(?:(\<.+>).*?)?$", "$1")
126-
select Tuple.Create(request, generics)
147+
// find all files in NEST ending with Request.cs
148+
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
149+
from l in File.ReadLines(f.FullName)
150+
// attempt to locate all Request interfaces lines
151+
where Regex.IsMatch(l, @"^.+interface [^ \r\n]+Request")
152+
//grab the interface name including any generics declared on it
153+
let c = Regex.Replace(l, @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
154+
where c.StartsWith("I") && c.Contains("Request")
155+
let request = Regex.Replace(c, "<.*$", "")
156+
let generics = Regex.Replace(c, @"^.*?(?:(\<.+>).*?)?$", "$1")
157+
select Tuple.Create(request, generics)
127158
)
128-
.OrderBy(v=>v.Item1)
159+
.OrderBy(v => v.Item1)
129160
.ToList();
130161

131162
public static readonly HashSet<string> GenericOnlyInterfaces = new HashSet<string>(AllKnownRequestInterfaces
@@ -135,69 +166,67 @@ select Tuple.Create(request, generics)
135166
.ToList());
136167

137168
public static readonly HashSet<string> DocumentRequests = new HashSet<string>((
138-
// find all files in NEST ending with Request.cs
139-
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
140-
from l in File.ReadLines(f.FullName)
141-
// attempt to locate all Request interfaces lines
142-
where Regex.IsMatch(l, @"^.+interface [^ \r\n]+Request")
143-
where l.Contains("IDocumentRequest")
144-
let c = Regex.Replace(l, @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
145-
//grab the interface name including any generics declared on it
146-
let request = Regex.Replace(c, "<.*$", "")
147-
select request
169+
// find all files in NEST ending with Request.cs
170+
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
171+
from l in File.ReadLines(f.FullName)
172+
// attempt to locate all Request interfaces lines
173+
where Regex.IsMatch(l, @"^.+interface [^ \r\n]+Request")
174+
where l.Contains("IDocumentRequest")
175+
let c = Regex.Replace(l, @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
176+
//grab the interface name including any generics declared on it
177+
let request = Regex.Replace(c, "<.*$", "")
178+
select request
148179
)
149180
.ToList());
150181

151182
public static readonly Dictionary<string, string> DescriptorConstructors = (
152-
// find all files in NEST ending with Request.cs
153-
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
154-
let descriptor = Path.GetFileNameWithoutExtension(f.Name).Replace("Request", "Descriptor")
155-
let re = $@"^.+public {descriptor}\(([^\r\n\)]+?)\).*$"
156-
from l in File.ReadLines(f.FullName)
157-
where Regex.IsMatch(l, re)
158-
let args = Regex.Replace(l, re, "$1", RegexOptions.Singleline)
159-
where !string.IsNullOrWhiteSpace(args) && !args.Contains(": base")
160-
select (Descriptor: descriptor, Args: args)
183+
// find all files in NEST ending with Request.cs
184+
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Request.cs", SearchOption.AllDirectories)
185+
let descriptor = Path.GetFileNameWithoutExtension(f.Name).Replace("Request", "Descriptor")
186+
let re = $@"^.+public {descriptor}\(([^\r\n\)]+?)\).*$"
187+
from l in File.ReadLines(f.FullName)
188+
where Regex.IsMatch(l, re)
189+
let args = Regex.Replace(l, re, "$1", RegexOptions.Singleline)
190+
where !string.IsNullOrWhiteSpace(args) && !args.Contains(": base")
191+
select (Descriptor: descriptor, Args: args)
161192
)
162193
.ToDictionary(r => r.Descriptor, r => r.Args);
163194

164195
public static readonly Dictionary<string, string> RequestInterfaceGenericsLookup =
165196
AllKnownRequestInterfaces
166-
.GroupBy(v=>v.Item1)
167-
.Select(g=>g.Last())
168-
.ToDictionary(k => k.Item1, v => v.Item2);
197+
.GroupBy(v => v.Item1)
198+
.Select(g => g.Last())
199+
.ToDictionary(k => k.Item1, v => v.Item2);
169200

170201
/// <summary>
171202
/// Some API's reuse response this is a hardcoded map of these cases
172203
/// </summary>
173204
private static Dictionary<string, (string, string)> ResponseReroute = new Dictionary<string, (string, string)>
174205
{
175-
{"UpdateByQueryRethrottleResponse", ("ListTasksResponse", "")},
176-
{"DeleteByQueryRethrottleResponse", ("ListTasksResponse", "")},
177-
{"MultiSearchTemplateResponse", ("MultiSearchResponse", "")},
178-
{"ScrollResponse", ("SearchResponse", "<TDocument>")},
179-
{"SearchTemplateResponse", ("SearchResponse", "<TDocument>")},
180-
206+
{ "UpdateByQueryRethrottleResponse", ("ListTasksResponse", "") },
207+
{ "DeleteByQueryRethrottleResponse", ("ListTasksResponse", "") },
208+
{ "MultiSearchTemplateResponse", ("MultiSearchResponse", "") },
209+
{ "ScrollResponse", ("SearchResponse", "<TDocument>") },
210+
{ "SearchTemplateResponse", ("SearchResponse", "<TDocument>") },
181211
};
182212

183213

184214
/// <summary> Create a dictionary lookup of all responses and their generics </summary>
185215
public static readonly SortedDictionary<string, (string, string)> ResponseLookup = new SortedDictionary<string, (string, string)>(
186-
(
187-
// find all files in NEST ending with Request.cs
188-
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Response.cs", SearchOption.AllDirectories)
189-
from l in File.ReadLines(f.FullName)
190-
// attempt to locate all Response class lines
191-
where Regex.IsMatch(l, @"^.+public class [^ \r\n]+Response")
192-
//grab the response name including any generics declared on it
193-
let c = Regex.Replace(l, @"^.+public class ([^ \r\n]+Response(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
194-
where c.Contains("Response")
195-
let response = Regex.Replace(c, "<.*$", "")
196-
let generics = Regex.Replace(c, @"^.*?(?:(\<.+>).*?)?$", "$1")
197-
select (response, (response, generics))
198-
)
199-
.Concat(ResponseReroute.Select(kv=>(kv.Key, (kv.Value.Item1, kv.Value.Item2))))
200-
.ToDictionary(t=>t.Item1, t=>t.Item2));
201-
216+
(
217+
// find all files in NEST ending with Request.cs
218+
from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*Response.cs", SearchOption.AllDirectories)
219+
from l in File.ReadLines(f.FullName)
220+
// attempt to locate all Response class lines
221+
where Regex.IsMatch(l, @"^.+public class [^ \r\n]+Response")
222+
//grab the response name including any generics declared on it
223+
let c = Regex.Replace(l, @"^.+public class ([^ \r\n]+Response(?:<[^>\r\n]+>)?[^ \r\n]*).*$", "$1", RegexOptions.Singleline)
224+
where c.Contains("Response")
225+
let response = Regex.Replace(c, "<.*$", "")
226+
let generics = Regex.Replace(c, @"^.*?(?:(\<.+>).*?)?$", "$1")
227+
select (response, (response, generics))
228+
)
229+
.Concat(ResponseReroute.Select(kv => (kv.Key, (kv.Value.Item1, kv.Value.Item2))))
230+
.ToDictionary(t => t.Item1, t => t.Item2));
202231
}
203232
}

src/ApiGenerator/RestSpecification/Core/cat.aliases.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"none",
6464
"all"
6565
],
66-
"default": ["all"],
66+
"default": "all",
6767
"description":"Whether to expand wildcard expression to concrete indices that are open, closed or both."
6868
}
6969
}

src/ApiGenerator/RestSpecification/Core/cat.health.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"type":"enum",
3838
"description":"The unit in which to display time values",
3939
"options":[
40-
"d (Days)",
41-
"h (Hours)",
42-
"m (Minutes)",
43-
"s (Seconds)",
44-
"ms (Milliseconds)",
45-
"micros (Microseconds)",
46-
"nanos (Nanoseconds)"
40+
"d",
41+
"h",
42+
"m",
43+
"s",
44+
"ms",
45+
"micros",
46+
"nanos"
4747
]
4848
},
4949
"ts":{

src/ApiGenerator/RestSpecification/Core/cat.indices.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"yellow",
6969
"red"
7070
],
71-
"default":null,
7271
"description":"A health status (\"green\", \"yellow\", or \"red\" to filter only indices matching the specified health status"
7372
},
7473
"help":{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"cluster.exists_component_template":{
3+
"documentation":{
4+
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html",
5+
"description":"Returns information about whether a particular component template exist"
6+
},
7+
"stability":"stable",
8+
"url":{
9+
"paths":[
10+
{
11+
"path":"/_component_template/{name}",
12+
"methods":[
13+
"HEAD"
14+
],
15+
"parts":{
16+
"name":{
17+
"type":"string",
18+
"description":"The name of the template"
19+
}
20+
}
21+
}
22+
]
23+
},
24+
"params":{
25+
"master_timeout":{
26+
"type":"time",
27+
"description":"Explicit operation timeout for connection to master node"
28+
},
29+
"local":{
30+
"type":"boolean",
31+
"description":"Return local information, do not retrieve the state from master node (default: false)"
32+
}
33+
}
34+
}
35+
}

src/ApiGenerator/RestSpecification/Core/cluster.health.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"yellow",
9898
"red"
9999
],
100-
"default":null,
101100
"description":"Wait until cluster is in a specific state"
102101
}
103102
}

src/ApiGenerator/RestSpecification/Core/delete_by_query.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
5757
},
5858
"conflicts":{
59-
"note":"This is not copied from search",
6059
"type":"enum",
6160
"options":[
6261
"abort",
@@ -160,7 +159,7 @@
160159
},
161160
"scroll_size":{
162161
"type":"number",
163-
"defaut_value":100,
162+
"default":100,
164163
"description":"Size on the scroll request powering the delete by query"
165164
},
166165
"wait_for_completion":{

src/ApiGenerator/RestSpecification/Core/get_script_context.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"get_script_context":{
33
"documentation":{
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html",
45
"description":"Returns all script contexts."
56
},
67
"stability":"experimental",

src/ApiGenerator/RestSpecification/Core/get_script_languages.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"get_script_languages":{
33
"documentation":{
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html",
45
"description":"Returns available script types, languages and contexts"
56
},
67
"stability":"experimental",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"indices.delete_index_template":{
3+
"documentation":{
4+
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html",
5+
"description":"Deletes an index template."
6+
},
7+
"stability":"stable",
8+
"url":{
9+
"paths":[
10+
{
11+
"path":"/_index_template/{name}",
12+
"methods":[
13+
"DELETE"
14+
],
15+
"parts":{
16+
"name":{
17+
"type":"string",
18+
"description":"The name of the template"
19+
}
20+
}
21+
}
22+
]
23+
},
24+
"params":{
25+
"timeout":{
26+
"type":"time",
27+
"description":"Explicit operation timeout"
28+
},
29+
"master_timeout":{
30+
"type":"time",
31+
"description":"Specify timeout for connection to master"
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)