diff --git a/src/ApiGenerator/RestSpecification/Core/ml.find_file_structure.json b/src/ApiGenerator/RestSpecification/Core/ml.find_file_structure.json new file mode 100644 index 00000000000..4bc7103bda9 --- /dev/null +++ b/src/ApiGenerator/RestSpecification/Core/ml.find_file_structure.json @@ -0,0 +1,101 @@ +{ + "ml.find_file_structure":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html", + "description":"Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch." + }, + "stability":"experimental", + "visibility":"public", + "headers":{ + "accept": [ "application/json"], + "content_type": ["application/x-ndjson"] + }, + "url":{ + "paths":[ + { + "path":"/_ml/find_file_structure", + "methods":[ + "POST" + ], + "deprecated":{ + "version":"7.12.0", + "description":"This endpoint has changed to _text_structure/find_structure, please use that API instead" + } + } + ] + }, + "params":{ + "lines_to_sample":{ + "type":"int", + "description":"How many lines of the file should be included in the analysis", + "default":1000 + }, + "line_merge_size_limit":{ + "type":"int", + "description":"Maximum number of characters permitted in a single message when lines are merged to create messages.", + "default":10000 + }, + "timeout":{ + "type":"time", + "description":"Timeout after which the analysis will be aborted", + "default":"25s" + }, + "charset":{ + "type":"string", + "description":"Optional parameter to specify the character set of the file" + }, + "format":{ + "type":"enum", + "options":[ + "ndjson", + "xml", + "delimited", + "semi_structured_text" + ], + "description":"Optional parameter to specify the high level file format" + }, + "has_header_row":{ + "type":"boolean", + "description":"Optional parameter to specify whether a delimited file includes the column names in its first row" + }, + "column_names":{ + "type":"list", + "description":"Optional parameter containing a comma separated list of the column names for a delimited file" + }, + "delimiter":{ + "type":"string", + "description":"Optional parameter to specify the delimiter character for a delimited file - must be a single character" + }, + "quote":{ + "type":"string", + "description":"Optional parameter to specify the quote character for a delimited file - must be a single character" + }, + "should_trim_fields":{ + "type":"boolean", + "description":"Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them" + }, + "grok_pattern":{ + "type":"string", + "description":"Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file" + }, + "timestamp_field":{ + "type":"string", + "description":"Optional parameter to specify the timestamp field in the file" + }, + "timestamp_format":{ + "type":"string", + "description":"Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format" + }, + "explain":{ + "type":"boolean", + "description":"Whether to include a commentary on how the structure was derived", + "default":false + } + }, + "body":{ + "description":"The contents of the file to be analyzed", + "required":true, + "serialize":"bulk" + } + } +} diff --git a/src/ApiGenerator/RestSpecification/Core/text_structure.find_structure.json b/src/ApiGenerator/RestSpecification/Core/text_structure.find_structure.json index 934bc7859e4..a0b8f9965f8 100644 --- a/src/ApiGenerator/RestSpecification/Core/text_structure.find_structure.json +++ b/src/ApiGenerator/RestSpecification/Core/text_structure.find_structure.json @@ -4,7 +4,7 @@ "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html", "description":"Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch." }, - "stability":"experimental", + "stability":"stable", "visibility":"public", "headers":{ "accept": [ "application/json"], diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs index fe928ff34a6..01a9ee9744a 100644 --- a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs +++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs @@ -681,7 +681,7 @@ public class PreviewDataFrameAnalyticsRequestParameters : RequestParametersRequest options for PreviewDatafeed https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html public class PreviewDatafeedRequestParameters : RequestParameters { - public override HttpMethod DefaultHttpMethod => HttpMethod.GET; + public override HttpMethod DefaultHttpMethod => HttpMethod.POST; public override bool SupportsBody => true; } diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs index 2cadad6e17b..34bd2fb272c 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs @@ -721,30 +721,30 @@ public TResponse PreviewDataFrameAnalytics(string id, PostData body, [MapsApi("ml.preview_data_frame_analytics", "id, body")] public Task PreviewDataFrameAnalyticsAsync(string id, PostData body, PreviewDataFrameAnalyticsRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(POST, Url($"_ml/data_frame/analytics/{id:id}/_preview"), ctx, body, RequestParams(requestParameters)); - ///GET on /_ml/datafeeds/{datafeed_id}/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + ///POST on /_ml/datafeeds/{datafeed_id}/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html ///The ID of the datafeed to preview ///The datafeed config and job config with which to execute the preview ///Request specific configuration such as querystring parameters & request specific connection settings. public TResponse PreviewDatafeed(string datafeedId, PostData body, PreviewDatafeedRequestParameters requestParameters = null) - where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, Url($"_ml/datafeeds/{datafeedId:datafeedId}/_preview"), body, RequestParams(requestParameters)); - ///GET on /_ml/datafeeds/{datafeed_id}/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + where TResponse : class, IElasticsearchResponse, new() => DoRequest(POST, Url($"_ml/datafeeds/{datafeedId:datafeedId}/_preview"), body, RequestParams(requestParameters)); + ///POST on /_ml/datafeeds/{datafeed_id}/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html ///The ID of the datafeed to preview ///The datafeed config and job config with which to execute the preview ///Request specific configuration such as querystring parameters & request specific connection settings. [MapsApi("ml.preview_datafeed", "datafeed_id, body")] public Task PreviewDatafeedAsync(string datafeedId, PostData body, PreviewDatafeedRequestParameters requestParameters = null, CancellationToken ctx = default) - where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, Url($"_ml/datafeeds/{datafeedId:datafeedId}/_preview"), ctx, body, RequestParams(requestParameters)); - ///GET on /_ml/datafeeds/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(POST, Url($"_ml/datafeeds/{datafeedId:datafeedId}/_preview"), ctx, body, RequestParams(requestParameters)); + ///POST on /_ml/datafeeds/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html ///The datafeed config and job config with which to execute the preview ///Request specific configuration such as querystring parameters & request specific connection settings. public TResponse PreviewDatafeed(PostData body, PreviewDatafeedRequestParameters requestParameters = null) - where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, "_ml/datafeeds/_preview", body, RequestParams(requestParameters)); - ///GET on /_ml/datafeeds/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + where TResponse : class, IElasticsearchResponse, new() => DoRequest(POST, "_ml/datafeeds/_preview", body, RequestParams(requestParameters)); + ///POST on /_ml/datafeeds/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html ///The datafeed config and job config with which to execute the preview ///Request specific configuration such as querystring parameters & request specific connection settings. [MapsApi("ml.preview_datafeed", "body")] public Task PreviewDatafeedAsync(PostData body, PreviewDatafeedRequestParameters requestParameters = null, CancellationToken ctx = default) - where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, "_ml/datafeeds/_preview", ctx, body, RequestParams(requestParameters)); + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(POST, "_ml/datafeeds/_preview", ctx, body, RequestParams(requestParameters)); ///PUT on /_ml/calendars/{calendar_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html ///The ID of the calendar to create ///The calendar details diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.TextStructure.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.TextStructure.cs index f9b202e92f8..38dff00a3ad 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.TextStructure.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.TextStructure.cs @@ -46,13 +46,11 @@ internal LowLevelTextStructureNamespace(ElasticLowLevelClient client): base(clie ///POST on /_text_structure/find_structure https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html ///The contents of the file to be analyzed ///Request specific configuration such as querystring parameters & request specific connection settings. - ///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. public TResponse FindStructure(PostData body, FindStructureRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new() => DoRequest(POST, "_text_structure/find_structure", body, RequestParams(requestParameters)); ///POST on /_text_structure/find_structure https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html ///The contents of the file to be analyzed ///Request specific configuration such as querystring parameters & request specific connection settings. - ///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. [MapsApi("text_structure.find_structure", "body")] public Task FindStructureAsync(PostData body, FindStructureRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(POST, "_text_structure/find_structure", ctx, body, RequestParams(requestParameters)); diff --git a/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedApiTests.cs b/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedApiTests.cs index 3aac9135173..4a53ada3cd5 100644 --- a/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedApiTests.cs +++ b/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedApiTests.cs @@ -22,7 +22,7 @@ public PreviewDatafeedApiTests(MachineLearningCluster cluster, EndpointUsage usa protected override object ExpectJson => null; protected override int ExpectStatusCode => 200; protected override Func Fluent => f => f; - protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override HttpMethod HttpMethod => HttpMethod.POST; protected override PreviewDatafeedRequest Initializer => new PreviewDatafeedRequest(CallIsolatedValue + "-datafeed"); protected override bool SupportsDeserialization => false; protected override string UrlPath => $"/_ml/datafeeds/{CallIsolatedValue}-datafeed/_preview"; diff --git a/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedUrlTests.cs b/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedUrlTests.cs index 5811ecdba9b..d9553159c4e 100644 --- a/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedUrlTests.cs +++ b/tests/Tests/XPack/MachineLearning/PreviewDataFeed/PreviewDataFeedUrlTests.cs @@ -12,7 +12,7 @@ namespace Tests.XPack.MachineLearning.PreviewDataFeed { public class PreviewDatafeedUrlTests : UrlTestsBase { - [U] public override async Task Urls() => await UrlTester.GET("/_ml/datafeeds/datafeed_id/_preview") + [U] public override async Task Urls() => await UrlTester.POST("/_ml/datafeeds/datafeed_id/_preview") .Fluent(c => c.MachineLearning.PreviewDatafeed("datafeed_id", p => p)) .Request(c => c.MachineLearning.PreviewDatafeed(new PreviewDatafeedRequest("datafeed_id"))) .FluentAsync(c => c.MachineLearning.PreviewDatafeedAsync("datafeed_id", p => p))