Skip to content

Commit e0b081d

Browse files
authored
Fix up incorrectly removed endpoint in 7.11 (#5536)
1 parent e9c752b commit e0b081d

File tree

5 files changed

+148
-7
lines changed

5 files changed

+148
-7
lines changed

src/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ public static class CodeConfiguration
3131
// To be removed
3232
"indices.upgrade.json",
3333
"indices.get_upgrade.json",
34-
35-
// This was added in 7.12.0 BC1 but the spec was removed before GA, but the API still existed.
36-
// This isn't the preferred API so skipping code gen for it.
37-
"ml.find_file_structure.json"
3834
};
3935

4036
private static string[] IgnoredApisHighLevel { get; } =

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,19 @@ public enum IndicesShardStoresStatus
411411
All
412412
}
413413

414+
[StringEnum]
415+
public enum MachineLearningFindFileStructureFormat
416+
{
417+
[EnumMember(Value = "ndjson")]
418+
Ndjson,
419+
[EnumMember(Value = "xml")]
420+
Xml,
421+
[EnumMember(Value = "delimited")]
422+
Delimited,
423+
[EnumMember(Value = "semi_structured_text")]
424+
SemiStructuredText
425+
}
426+
414427
[StringEnum]
415428
public enum ThreadType
416429
{
@@ -461,6 +474,7 @@ static KnownEnums()
461474
EnumStringResolvers.TryAdd(typeof(Conflicts), (e) => GetStringValue((Conflicts)e));
462475
EnumStringResolvers.TryAdd(typeof(OpType), (e) => GetStringValue((OpType)e));
463476
EnumStringResolvers.TryAdd(typeof(IndicesShardStoresStatus), (e) => GetStringValue((IndicesShardStoresStatus)e));
477+
EnumStringResolvers.TryAdd(typeof(MachineLearningFindFileStructureFormat), (e) => GetStringValue((MachineLearningFindFileStructureFormat)e));
464478
EnumStringResolvers.TryAdd(typeof(ThreadType), (e) => GetStringValue((ThreadType)e));
465479
EnumStringResolvers.TryAdd(typeof(GroupBy), (e) => GetStringValue((GroupBy)e));
466480
}
@@ -933,6 +947,23 @@ public static string GetStringValue(this IndicesShardStoresStatus enumValue)
933947
throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'IndicesShardStoresStatus'");
934948
}
935949

950+
public static string GetStringValue(this MachineLearningFindFileStructureFormat enumValue)
951+
{
952+
switch (enumValue)
953+
{
954+
case MachineLearningFindFileStructureFormat.Ndjson:
955+
return "ndjson";
956+
case MachineLearningFindFileStructureFormat.Xml:
957+
return "xml";
958+
case MachineLearningFindFileStructureFormat.Delimited:
959+
return "delimited";
960+
case MachineLearningFindFileStructureFormat.SemiStructuredText:
961+
return "semi_structured_text";
962+
}
963+
964+
throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'MachineLearningFindFileStructureFormat'");
965+
}
966+
936967
public static string GetStringValue(this ThreadType enumValue)
937968
{
938969
switch (enumValue)

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,110 @@ public class ExplainDataFrameAnalyticsRequestParameters : RequestParameters<Expl
215215
public override bool SupportsBody => true;
216216
}
217217

218+
///<summary>Request options for FindFileStructure <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html</para></summary>
219+
public class FindFileStructureRequestParameters : RequestParameters<FindFileStructureRequestParameters>
220+
{
221+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
222+
public override bool SupportsBody => true;
223+
///<summary>Optional parameter to specify the character set of the file</summary>
224+
public string Charset
225+
{
226+
get => Q<string>("charset");
227+
set => Q("charset", value);
228+
}
229+
230+
///<summary>Optional parameter containing a comma separated list of the column names for a delimited file</summary>
231+
public string[] ColumnNames
232+
{
233+
get => Q<string[]>("column_names");
234+
set => Q("column_names", value);
235+
}
236+
237+
///<summary>Optional parameter to specify the delimiter character for a delimited file - must be a single character</summary>
238+
public string Delimiter
239+
{
240+
get => Q<string>("delimiter");
241+
set => Q("delimiter", value);
242+
}
243+
244+
///<summary>Whether to include a commentary on how the structure was derived</summary>
245+
public bool? Explain
246+
{
247+
get => Q<bool? >("explain");
248+
set => Q("explain", value);
249+
}
250+
251+
///<summary>Optional parameter to specify the high level file format</summary>
252+
public MachineLearningFindFileStructureFormat? MachineLearningFindFileStructureFormat
253+
{
254+
get => Q<MachineLearningFindFileStructureFormat? >("format");
255+
set => Q("format", value);
256+
}
257+
258+
///<summary>Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file</summary>
259+
public string GrokPattern
260+
{
261+
get => Q<string>("grok_pattern");
262+
set => Q("grok_pattern", value);
263+
}
264+
265+
///<summary>Optional parameter to specify whether a delimited file includes the column names in its first row</summary>
266+
public bool? HasHeaderRow
267+
{
268+
get => Q<bool? >("has_header_row");
269+
set => Q("has_header_row", value);
270+
}
271+
272+
///<summary>Maximum number of characters permitted in a single message when lines are merged to create messages.</summary>
273+
public int? LineMergeSizeLimit
274+
{
275+
get => Q<int? >("line_merge_size_limit");
276+
set => Q("line_merge_size_limit", value);
277+
}
278+
279+
///<summary>How many lines of the file should be included in the analysis</summary>
280+
public int? LinesToSample
281+
{
282+
get => Q<int? >("lines_to_sample");
283+
set => Q("lines_to_sample", value);
284+
}
285+
286+
///<summary>Optional parameter to specify the quote character for a delimited file - must be a single character</summary>
287+
public string Quote
288+
{
289+
get => Q<string>("quote");
290+
set => Q("quote", value);
291+
}
292+
293+
///<summary>Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them</summary>
294+
public bool? ShouldTrimFields
295+
{
296+
get => Q<bool? >("should_trim_fields");
297+
set => Q("should_trim_fields", value);
298+
}
299+
300+
///<summary>Timeout after which the analysis will be aborted</summary>
301+
public TimeSpan Timeout
302+
{
303+
get => Q<TimeSpan>("timeout");
304+
set => Q("timeout", value);
305+
}
306+
307+
///<summary>Optional parameter to specify the timestamp field in the file</summary>
308+
public string TimestampField
309+
{
310+
get => Q<string>("timestamp_field");
311+
set => Q("timestamp_field", value);
312+
}
313+
314+
///<summary>Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format</summary>
315+
public string TimestampFormat
316+
{
317+
get => Q<string>("timestamp_format");
318+
set => Q("timestamp_format", value);
319+
}
320+
}
321+
218322
///<summary>Request options for FlushJob <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html</para></summary>
219323
public class FlushJobRequestParameters : RequestParameters<FlushJobRequestParameters>
220324
{

src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ public TResponse ExplainDataFrameAnalytics<TResponse>(string id, PostData body,
254254
[MapsApi("ml.explain_data_frame_analytics", "id, body")]
255255
public Task<TResponse> ExplainDataFrameAnalyticsAsync<TResponse>(string id, PostData body, ExplainDataFrameAnalyticsRequestParameters requestParameters = null, CancellationToken ctx = default)
256256
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"_ml/data_frame/analytics/{id:id}/_explain"), ctx, body, RequestParams(requestParameters));
257+
///<summary>POST on /_ml/find_file_structure <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html</para></summary>
258+
///<param name = "body">The contents of the file to be analyzed</param>
259+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
260+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
261+
public TResponse FindFileStructure<TResponse>(PostData body, FindFileStructureRequestParameters requestParameters = null)
262+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, "_ml/find_file_structure", body, RequestParams(requestParameters));
263+
///<summary>POST on /_ml/find_file_structure <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html</para></summary>
264+
///<param name = "body">The contents of the file to be analyzed</param>
265+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
266+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
267+
[MapsApi("ml.find_file_structure", "body")]
268+
public Task<TResponse> FindFileStructureAsync<TResponse>(PostData body, FindFileStructureRequestParameters requestParameters = null, CancellationToken ctx = default)
269+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, "_ml/find_file_structure", ctx, body, RequestParams(requestParameters));
257270
///<summary>POST on /_ml/anomaly_detectors/{job_id}/_flush <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html</para></summary>
258271
///<param name = "jobId">The name of the job to flush</param>
259272
///<param name = "body">Flush parameters</param>

tests/Tests.YamlRunner/SkipList.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,4 @@ let SkipList = dict<SkipFile,SkipSection> [
182182

183183
// TODO investigate post 7.11.0
184184
SkipFile "nodes.info/10_basic.yml", Section "node_info role test"
185-
186185
]
187-
188-

0 commit comments

Comments
 (0)