From 3c7303f71d0327dd3ac378ab5ff4774ccf7dd493 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Wed, 31 Mar 2021 19:47:10 +0100 Subject: [PATCH] Patch preview ML datafeed spec and re-gen code --- .../_Patches/ml.preview_datafeed.patch.json | 7 +++++++ .../RequestParameters.MachineLearning.cs | 2 +- .../ElasticLowLevelClient.MachineLearning.cs | 16 ++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 src/ApiGenerator/RestSpecification/_Patches/ml.preview_datafeed.patch.json diff --git a/src/ApiGenerator/RestSpecification/_Patches/ml.preview_datafeed.patch.json b/src/ApiGenerator/RestSpecification/_Patches/ml.preview_datafeed.patch.json new file mode 100644 index 00000000000..727042d36f5 --- /dev/null +++ b/src/ApiGenerator/RestSpecification/_Patches/ml.preview_datafeed.patch.json @@ -0,0 +1,7 @@ +{ + "ml.preview_datafeed": { + "methods": [ + "GET" + ] + } +} \ No newline at end of file diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.MachineLearning.cs index 01a9ee9744a..fe928ff34a6 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.POST; + public override HttpMethod DefaultHttpMethod => HttpMethod.GET; public override bool SupportsBody => true; } diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.MachineLearning.cs index 34bd2fb272c..2cadad6e17b 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)); - ///POST on /_ml/datafeeds/{datafeed_id}/_preview https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + ///GET 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(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 + 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 ///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(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 + 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 ///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(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 + 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 ///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(POST, "_ml/datafeeds/_preview", ctx, body, RequestParams(requestParameters)); + where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, "_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