@@ -15,18 +15,13 @@ public static class CodeConfiguration
1515 "monitoring.bulk.json" ,
1616
1717 // Never exposed and now deprecated
18- "data_frame_transform_deprecated.delete_transform.json" ,
19- "data_frame_transform_deprecated.get_transform.json" ,
20- "data_frame_transform_deprecated.get_transform_stats.json" ,
21- "data_frame_transform_deprecated.preview_transform.json" ,
22- "data_frame_transform_deprecated.put_transform.json" ,
23- "data_frame_transform_deprecated.start_transform.json" ,
24- "data_frame_transform_deprecated.stop_transform.json" ,
25- "data_frame_transform_deprecated.update_transform.json" ,
18+ "data_frame_transform_deprecated.delete_transform.json" , "data_frame_transform_deprecated.get_transform.json" ,
19+ "data_frame_transform_deprecated.get_transform_stats.json" , "data_frame_transform_deprecated.preview_transform.json" ,
20+ "data_frame_transform_deprecated.put_transform.json" , "data_frame_transform_deprecated.start_transform.json" ,
21+ "data_frame_transform_deprecated.stop_transform.json" , "data_frame_transform_deprecated.update_transform.json" ,
2622
2723 // To be removed
28- "indices.upgrade.json" ,
29- "indices.get_upgrade.json" ,
24+ "indices.upgrade.json" , "indices.get_upgrade.json" ,
3025 } ;
3126
3227 public static string [ ] IgnoredApisHighLevel { get ; } =
@@ -55,37 +50,31 @@ public static class CodeConfiguration
5550 "scripts_painless_context.json" , // 7.7 experimental
5651
5752 // 7.7 - to be implemented
58- "async_search.delete.json" ,
59- "async_search.get.json" ,
60- "async_search.submit.json" ,
61- "cat.ml_data_frame_analytics.json" ,
62- "cat.ml_datafeeds.json" ,
63- "cat.ml_jobs.json" ,
64- "cat.ml_trained_models.json" ,
65- "cat.transforms.json" ,
66- "cluster.delete_component_template.json" ,
67- "cluster.get_component_template.json" ,
68- "cluster.put_component_template.json" ,
69- "indices.reload_search_analyzers.json" ,
70- "ml.estimate_model_memory.json" ,
71- "ml.set_upgrade_mode.json" ,
72- "security.get_builtin_privileges.json" ,
73- "transform.delete_transform.json" ,
74- "transform.get_transform.json" ,
75- "transform.get_transform_stats.json" ,
76- "transform.preview_transform.json" ,
77- "transform.put_transform.json" ,
78- "transform.start_transform.json" ,
79- "transform.stop_transform.json" ,
80- "transform.update_transform.json" ,
53+ "async_search.delete.json" , "async_search.get.json" , "async_search.submit.json" , "cat.ml_data_frame_analytics.json" ,
54+ "cat.ml_datafeeds.json" , "cat.ml_jobs.json" , "cat.ml_trained_models.json" , "cat.transforms.json" ,
55+ "cluster.delete_component_template.json" , "cluster.get_component_template.json" , "cluster.put_component_template.json" ,
56+ "indices.reload_search_analyzers.json" , "ml.estimate_model_memory.json" , "ml.set_upgrade_mode.json" ,
57+ "security.get_builtin_privileges.json" , "transform.delete_transform.json" , "transform.get_transform.json" ,
58+ "transform.get_transform_stats.json" , "transform.preview_transform.json" , "transform.put_transform.json" ,
59+ "transform.start_transform.json" , "transform.stop_transform.json" , "transform.update_transform.json" ,
8160 } ;
8261
8362
63+ /// <summary>
64+ /// Map API default names for API's we are only supporting on the low level client first
65+ /// </summary>
66+ private static readonly Dictionary < string , string > LowLevelApiNameMapping = new Dictionary < string , string >
67+ {
68+ { "indices.delete_index_template" , "DeleteIndexTemplateV2" } ,
69+ { "indices.get_index_template" , "GetIndexTemplateV2" } ,
70+ { "indices.put_index_template" , "PutIndexTemplateV2" }
71+ } ;
72+
8473 /// <summary>
8574 /// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
8675 /// The class name minus Request is used as the canonical .NET name for the API.
8776 /// </summary>
88- public static readonly Dictionary < string , string > ApiNameMapping =
77+ private static readonly Dictionary < string , string > HighLevelApiNameMapping =
8978 ( from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*.cs" , SearchOption . AllDirectories )
9079 let contents = File . ReadAllText ( f . FullName )
9180 let c = Regex . Replace ( contents , @"^.+\[MapsApi\(""([^ \r\n]+)""\)\].*$" , "$1" , RegexOptions . Singleline )
@@ -94,7 +83,28 @@ public static class CodeConfiguration
9483 . DistinctBy ( v => v . Key )
9584 . ToDictionary ( k => k . Key , v => v . Value . Replace ( ".cs" , "" ) ) ;
9685
86+ private static Dictionary < string , string > _apiNameMapping ;
87+
88+ public static Dictionary < string , string > ApiNameMapping
89+ {
90+ get
91+ {
92+ if ( _apiNameMapping != null ) return _apiNameMapping ;
93+ lock ( LowLevelApiNameMapping )
94+ {
95+ if ( _apiNameMapping != null ) return _apiNameMapping ;
96+
97+ var mapping = HighLevelApiNameMapping ;
98+ foreach ( var ( k , v ) in LowLevelApiNameMapping )
99+ mapping [ k ] = v ;
100+ _apiNameMapping = mapping ;
101+ return _apiNameMapping ;
102+ }
103+ }
104+ }
105+
97106 private static readonly string ResponseBuilderAttributeRegex = @"^.+\[ResponseBuilderWithGeneric\(""([^ \r\n]+)""\)\].*$" ;
107+
98108 /// <summary>
99109 /// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
100110 /// The class name minus Request is used as the canonical .NET name for the API.
@@ -121,19 +131,19 @@ where Regex.IsMatch(l, ResponseBuilderAttributeRegex)
121131
122132 /// <summary> Scan all NEST files for request interfaces and note any generics declared on them </summary>
123133 private static readonly List < Tuple < string , string > > AllKnownRequestInterfaces = (
124- // find all files in NEST ending with Request.cs
125- from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
126- from l in File . ReadLines ( f . FullName )
127- // attempt to locate all Request interfaces lines
128- where Regex . IsMatch ( l , @"^.+interface [^ \r\n]+Request" )
129- //grab the interface name including any generics declared on it
130- let c = Regex . Replace ( l , @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
131- where c . StartsWith ( "I" ) && c . Contains ( "Request" )
132- let request = Regex . Replace ( c , "<.*$" , "" )
133- let generics = Regex . Replace ( c , @"^.*?(?:(\<.+>).*?)?$" , "$1" )
134- select Tuple . Create ( request , generics )
134+ // find all files in NEST ending with Request.cs
135+ from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
136+ from l in File . ReadLines ( f . FullName )
137+ // attempt to locate all Request interfaces lines
138+ where Regex . IsMatch ( l , @"^.+interface [^ \r\n]+Request" )
139+ //grab the interface name including any generics declared on it
140+ let c = Regex . Replace ( l , @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
141+ where c . StartsWith ( "I" ) && c . Contains ( "Request" )
142+ let request = Regex . Replace ( c , "<.*$" , "" )
143+ let generics = Regex . Replace ( c , @"^.*?(?:(\<.+>).*?)?$" , "$1" )
144+ select Tuple . Create ( request , generics )
135145 )
136- . OrderBy ( v=> v . Item1 )
146+ . OrderBy ( v => v . Item1 )
137147 . ToList ( ) ;
138148
139149 public static readonly HashSet < string > GenericOnlyInterfaces = new HashSet < string > ( AllKnownRequestInterfaces
@@ -143,69 +153,67 @@ select Tuple.Create(request, generics)
143153 . ToList ( ) ) ;
144154
145155 public static readonly HashSet < string > DocumentRequests = new HashSet < string > ( (
146- // find all files in NEST ending with Request.cs
147- from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
148- from l in File . ReadLines ( f . FullName )
149- // attempt to locate all Request interfaces lines
150- where Regex . IsMatch ( l , @"^.+interface [^ \r\n]+Request" )
151- where l . Contains ( "IDocumentRequest" )
152- let c = Regex . Replace ( l , @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
153- //grab the interface name including any generics declared on it
154- let request = Regex . Replace ( c , "<.*$" , "" )
155- select request
156+ // find all files in NEST ending with Request.cs
157+ from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
158+ from l in File . ReadLines ( f . FullName )
159+ // attempt to locate all Request interfaces lines
160+ where Regex . IsMatch ( l , @"^.+interface [^ \r\n]+Request" )
161+ where l . Contains ( "IDocumentRequest" )
162+ let c = Regex . Replace ( l , @"^.+interface ([^ \r\n]+Request(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
163+ //grab the interface name including any generics declared on it
164+ let request = Regex . Replace ( c , "<.*$" , "" )
165+ select request
156166 )
157167 . ToList ( ) ) ;
158168
159169 public static readonly Dictionary < string , string > DescriptorConstructors = (
160- // find all files in NEST ending with Request.cs
161- from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
162- let descriptor = Path . GetFileNameWithoutExtension ( f . Name ) . Replace ( "Request" , "Descriptor" )
163- let re = $@ "^.+public { descriptor } \(([^\r\n\)]+?)\).*$"
164- from l in File . ReadLines ( f . FullName )
165- where Regex . IsMatch ( l , re )
166- let args = Regex . Replace ( l , re , "$1" , RegexOptions . Singleline )
167- where ! string . IsNullOrWhiteSpace ( args ) && ! args . Contains ( ": base" )
168- select ( Descriptor : descriptor , Args : args )
170+ // find all files in NEST ending with Request.cs
171+ from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Request.cs" , SearchOption . AllDirectories )
172+ let descriptor = Path . GetFileNameWithoutExtension ( f . Name ) . Replace ( "Request" , "Descriptor" )
173+ let re = $@ "^.+public { descriptor } \(([^\r\n\)]+?)\).*$"
174+ from l in File . ReadLines ( f . FullName )
175+ where Regex . IsMatch ( l , re )
176+ let args = Regex . Replace ( l , re , "$1" , RegexOptions . Singleline )
177+ where ! string . IsNullOrWhiteSpace ( args ) && ! args . Contains ( ": base" )
178+ select ( Descriptor : descriptor , Args : args )
169179 )
170180 . ToDictionary ( r => r . Descriptor , r => r . Args ) ;
171181
172182 public static readonly Dictionary < string , string > RequestInterfaceGenericsLookup =
173183 AllKnownRequestInterfaces
174- . GroupBy ( v=> v . Item1 )
175- . Select ( g=> g . Last ( ) )
176- . ToDictionary ( k => k . Item1 , v => v . Item2 ) ;
184+ . GroupBy ( v => v . Item1 )
185+ . Select ( g => g . Last ( ) )
186+ . ToDictionary ( k => k . Item1 , v => v . Item2 ) ;
177187
178188 /// <summary>
179189 /// Some API's reuse response this is a hardcoded map of these cases
180190 /// </summary>
181191 private static Dictionary < string , ( string , string ) > ResponseReroute = new Dictionary < string , ( string , string ) >
182192 {
183- { "UpdateByQueryRethrottleResponse" , ( "ListTasksResponse" , "" ) } ,
184- { "DeleteByQueryRethrottleResponse" , ( "ListTasksResponse" , "" ) } ,
185- { "MultiSearchTemplateResponse" , ( "MultiSearchResponse" , "" ) } ,
186- { "ScrollResponse" , ( "SearchResponse" , "<TDocument>" ) } ,
187- { "SearchTemplateResponse" , ( "SearchResponse" , "<TDocument>" ) } ,
188-
193+ { "UpdateByQueryRethrottleResponse" , ( "ListTasksResponse" , "" ) } ,
194+ { "DeleteByQueryRethrottleResponse" , ( "ListTasksResponse" , "" ) } ,
195+ { "MultiSearchTemplateResponse" , ( "MultiSearchResponse" , "" ) } ,
196+ { "ScrollResponse" , ( "SearchResponse" , "<TDocument>" ) } ,
197+ { "SearchTemplateResponse" , ( "SearchResponse" , "<TDocument>" ) } ,
189198 } ;
190199
191200
192201 /// <summary> Create a dictionary lookup of all responses and their generics </summary>
193202 public static readonly SortedDictionary < string , ( string , string ) > ResponseLookup = new SortedDictionary < string , ( string , string ) > (
194- (
195- // find all files in NEST ending with Request.cs
196- from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Response.cs" , SearchOption . AllDirectories )
197- from l in File . ReadLines ( f . FullName )
198- // attempt to locate all Response class lines
199- where Regex . IsMatch ( l , @"^.+public class [^ \r\n]+Response" )
200- //grab the response name including any generics declared on it
201- let c = Regex . Replace ( l , @"^.+public class ([^ \r\n]+Response(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
202- where c . Contains ( "Response" )
203- let response = Regex . Replace ( c , "<.*$" , "" )
204- let generics = Regex . Replace ( c , @"^.*?(?:(\<.+>).*?)?$" , "$1" )
205- select ( response , ( response , generics ) )
206- )
207- . Concat ( ResponseReroute . Select ( kv=> ( kv . Key , ( kv . Value . Item1 , kv . Value . Item2 ) ) ) )
208- . ToDictionary ( t=> t . Item1 , t=> t . Item2 ) ) ;
209-
203+ (
204+ // find all files in NEST ending with Request.cs
205+ from f in new DirectoryInfo ( GeneratorLocations . NestFolder ) . GetFiles ( "*Response.cs" , SearchOption . AllDirectories )
206+ from l in File . ReadLines ( f . FullName )
207+ // attempt to locate all Response class lines
208+ where Regex . IsMatch ( l , @"^.+public class [^ \r\n]+Response" )
209+ //grab the response name including any generics declared on it
210+ let c = Regex . Replace ( l , @"^.+public class ([^ \r\n]+Response(?:<[^>\r\n]+>)?[^ \r\n]*).*$" , "$1" , RegexOptions . Singleline )
211+ where c . Contains ( "Response" )
212+ let response = Regex . Replace ( c , "<.*$" , "" )
213+ let generics = Regex . Replace ( c , @"^.*?(?:(\<.+>).*?)?$" , "$1" )
214+ select ( response , ( response , generics ) )
215+ )
216+ . Concat ( ResponseReroute . Select ( kv => ( kv . Key , ( kv . Value . Item1 , kv . Value . Item2 ) ) ) )
217+ . ToDictionary ( t => t . Item1 , t => t . Item2 ) ) ;
210218 }
211219}
0 commit comments