Skip to content

Commit 71c37bb

Browse files
codebraingithub-actions[bot]
authored andcommitted
Implement cat.ml_datafeeds (#4564)
Implement cat.ml_datafeeds
1 parent a002a72 commit 71c37bb

File tree

12 files changed

+315
-8
lines changed

12 files changed

+315
-8
lines changed

src/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public static class CodeConfiguration
5959
"async_search.get.json",
6060
"async_search.submit.json",
6161
"cat.ml_data_frame_analytics.json",
62-
"cat.ml_datafeeds.json",
6362
"cluster.delete_component_template.json",
6463
"cluster.get_component_template.json",
6564
"cluster.put_component_template.json",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ public bool? Verbose
584584
}
585585
}
586586

587-
///<summary>Request options for MlDatafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
588-
public class MlDatafeedsRequestParameters : RequestParameters<MlDatafeedsRequestParameters>
587+
///<summary>Request options for Datafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
588+
public class CatDatafeedsRequestParameters : RequestParameters<CatDatafeedsRequestParameters>
589589
{
590590
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
591591
///<summary>Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified)</summary>

src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,23 @@ public Task<TResponse> MlDataFrameAnalyticsAsync<TResponse>(string id, MlDataFra
198198
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/ml/data_frame/analytics/{id:id}"), ctx, null, RequestParams(requestParameters));
199199
///<summary>GET on /_cat/ml/datafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
200200
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
201-
public TResponse MlDatafeeds<TResponse>(MlDatafeedsRequestParameters requestParameters = null)
201+
public TResponse Datafeeds<TResponse>(CatDatafeedsRequestParameters requestParameters = null)
202202
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, "_cat/ml/datafeeds", null, RequestParams(requestParameters));
203203
///<summary>GET on /_cat/ml/datafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
204204
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
205205
[MapsApi("cat.ml_datafeeds", "")]
206-
public Task<TResponse> MlDatafeedsAsync<TResponse>(MlDatafeedsRequestParameters requestParameters = null, CancellationToken ctx = default)
206+
public Task<TResponse> DatafeedsAsync<TResponse>(CatDatafeedsRequestParameters requestParameters = null, CancellationToken ctx = default)
207207
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, "_cat/ml/datafeeds", ctx, null, RequestParams(requestParameters));
208208
///<summary>GET on /_cat/ml/datafeeds/{datafeed_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
209209
///<param name = "datafeedId">The ID of the datafeeds stats to fetch</param>
210210
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
211-
public TResponse MlDatafeeds<TResponse>(string datafeedId, MlDatafeedsRequestParameters requestParameters = null)
211+
public TResponse Datafeeds<TResponse>(string datafeedId, CatDatafeedsRequestParameters requestParameters = null)
212212
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, Url($"_cat/ml/datafeeds/{datafeedId:datafeedId}"), null, RequestParams(requestParameters));
213213
///<summary>GET on /_cat/ml/datafeeds/{datafeed_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
214214
///<param name = "datafeedId">The ID of the datafeeds stats to fetch</param>
215215
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
216216
[MapsApi("cat.ml_datafeeds", "datafeed_id")]
217-
public Task<TResponse> MlDatafeedsAsync<TResponse>(string datafeedId, MlDatafeedsRequestParameters requestParameters = null, CancellationToken ctx = default)
217+
public Task<TResponse> DatafeedsAsync<TResponse>(string datafeedId, CatDatafeedsRequestParameters requestParameters = null, CancellationToken ctx = default)
218218
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/ml/datafeeds/{datafeedId:datafeedId}"), ctx, null, RequestParams(requestParameters));
219219
///<summary>GET on /_cat/ml/anomaly_detectors <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html</para></summary>
220220
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System.Runtime.Serialization;
2+
using Elasticsearch.Net.Utf8Json;
3+
4+
namespace Nest
5+
{
6+
[DataContract]
7+
public class CatDatafeedsRecord : ICatRecord
8+
{
9+
/// <summary>
10+
/// For started datafeeds only, contains messages relating to the selection of a node.
11+
/// </summary>
12+
[DataMember(Name="assignment_explanation")]
13+
public string AssignmentExplanation { get; internal set; }
14+
15+
/// <summary>
16+
/// (Default) The number of buckets processed.
17+
/// </summary>
18+
[DataMember(Name="buckets.count")]
19+
public string BucketsCount { get; internal set; }
20+
21+
/// <summary>
22+
/// (Default) A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase alphanumeric
23+
/// characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric characters.
24+
/// </summary>
25+
[DataMember(Name="id")]
26+
public string Id { get; internal set; }
27+
28+
/// <summary>
29+
/// The network address of the node. For started datafeeds only, this information pertains to the node upon which the datafeed is started.
30+
/// </summary>
31+
[DataMember(Name="node.address")]
32+
public string NodeAddress { get; internal set; }
33+
34+
/// <summary>
35+
/// The ephemeral ID of the node. For started datafeeds only, this information pertains to the node upon which the datafeed is started.
36+
/// </summary>
37+
[DataMember(Name="node.ephemeral_id")]
38+
public string NodeEphemeralId { get; internal set; }
39+
40+
/// <summary>
41+
/// The unique identifier of the node. For started datafeeds only, this information pertains to the node upon which the datafeed is started.
42+
/// </summary>
43+
[DataMember(Name="node.id")]
44+
public string NodeId { get; internal set; }
45+
46+
/// <summary>
47+
/// The node name. For started datafeeds only, this information pertains to the node upon which the datafeed is started.
48+
/// </summary>
49+
[DataMember(Name="node.name")]
50+
public string NodeName { get; internal set; }
51+
52+
/// <summary>
53+
/// The average search time per bucket, in milliseconds.
54+
/// </summary>
55+
[DataMember(Name="search.bucket_avg")]
56+
public string SearchBucketAvg { get; internal set; }
57+
58+
/// <summary>
59+
/// (Default) The number of searches run by the datafeed.
60+
/// </summary>
61+
[DataMember(Name="search.count")]
62+
public string SearchCount { get; internal set; }
63+
64+
/// <summary>
65+
/// The exponential average search time per hour, in milliseconds.
66+
/// </summary>
67+
[DataMember(Name="search.exp_avg_hour")]
68+
public string SearchExpAvgHour { get; internal set; }
69+
70+
/// <summary>
71+
/// The total time the datafeed spent searching, in milliseconds.
72+
/// </summary>
73+
[DataMember(Name="search.time")]
74+
public string SearchTime { get; internal set; }
75+
76+
/// <summary>
77+
/// The status of the datafeed.
78+
/// </summary>
79+
[DataMember(Name="state")]
80+
public DatafeedState State { get; internal set; }
81+
}
82+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Nest
2+
{
3+
[MapsApi("cat.ml_datafeeds.json")]
4+
public partial interface ICatDatafeedsRequest { }
5+
6+
public partial class CatDatafeedsRequest { }
7+
8+
public partial class CatDatafeedsDescriptor { }
9+
}

src/Nest/Descriptors.Cat.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,40 @@ public partial class CatMasterDescriptor : RequestDescriptorBase<CatMasterDescri
296296
public CatMasterDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
297297
}
298298

299+
///<summary>Descriptor for Datafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
300+
public partial class CatDatafeedsDescriptor : RequestDescriptorBase<CatDatafeedsDescriptor, CatDatafeedsRequestParameters, ICatDatafeedsRequest>, ICatDatafeedsRequest
301+
{
302+
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatDatafeeds;
303+
///<summary>/_cat/ml/datafeeds</summary>
304+
public CatDatafeedsDescriptor(): base()
305+
{
306+
}
307+
308+
///<summary>/_cat/ml/datafeeds/{datafeed_id}</summary>
309+
///<param name = "datafeedId">Optional, accepts null</param>
310+
public CatDatafeedsDescriptor(Id datafeedId): base(r => r.Optional("datafeed_id", datafeedId))
311+
{
312+
}
313+
314+
// values part of the url path
315+
Id ICatDatafeedsRequest.DatafeedId => Self.RouteValues.Get<Id>("datafeed_id");
316+
///<summary>The ID of the datafeeds stats to fetch</summary>
317+
public CatDatafeedsDescriptor DatafeedId(Id datafeedId) => Assign(datafeedId, (a, v) => a.RouteValues.Optional("datafeed_id", v));
318+
// Request parameters
319+
///<summary>Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified)</summary>
320+
public CatDatafeedsDescriptor AllowNoDatafeeds(bool? allownodatafeeds = true) => Qs("allow_no_datafeeds", allownodatafeeds);
321+
///<summary>a short version of the Accept header, e.g. json, yaml</summary>
322+
public CatDatafeedsDescriptor Format(string format) => Qs("format", format);
323+
///<summary>Comma-separated list of column names to display</summary>
324+
public CatDatafeedsDescriptor Headers(params string[] headers) => Qs("h", headers);
325+
///<summary>Return help information</summary>
326+
public CatDatafeedsDescriptor Help(bool? help = true) => Qs("help", help);
327+
///<summary>Comma-separated list of column names or column aliases to sort by</summary>
328+
public CatDatafeedsDescriptor SortByColumns(params string[] sortbycolumns) => Qs("s", sortbycolumns);
329+
///<summary>Verbose mode. Display column headers</summary>
330+
public CatDatafeedsDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
331+
}
332+
299333
///<summary>Descriptor for Jobs <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html</para></summary>
300334
public partial class CatJobsDescriptor : RequestDescriptorBase<CatJobsDescriptor, CatJobsRequestParameters, ICatJobsRequest>, ICatJobsRequest
301335
{

src/Nest/ElasticClient.Cat.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,30 @@ internal CatNamespace(ElasticClient client): base(client)
229229
/// </summary>
230230
public Task<CatResponse<CatMasterRecord>> MasterAsync(ICatMasterRequest request, CancellationToken ct = default) => DoCatAsync<ICatMasterRequest, CatMasterRequestParameters, CatMasterRecord>(request, ct);
231231
/// <summary>
232+
/// <c>GET</c> request to the <c>cat.ml_datafeeds</c> API, read more about this API online:
233+
/// <para></para>
234+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</a>
235+
/// </summary>
236+
public CatResponse<CatDatafeedsRecord> Datafeeds(Func<CatDatafeedsDescriptor, ICatDatafeedsRequest> selector = null) => Datafeeds(selector.InvokeOrDefault(new CatDatafeedsDescriptor()));
237+
/// <summary>
238+
/// <c>GET</c> request to the <c>cat.ml_datafeeds</c> API, read more about this API online:
239+
/// <para></para>
240+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</a>
241+
/// </summary>
242+
public Task<CatResponse<CatDatafeedsRecord>> DatafeedsAsync(Func<CatDatafeedsDescriptor, ICatDatafeedsRequest> selector = null, CancellationToken ct = default) => DatafeedsAsync(selector.InvokeOrDefault(new CatDatafeedsDescriptor()), ct);
243+
/// <summary>
244+
/// <c>GET</c> request to the <c>cat.ml_datafeeds</c> API, read more about this API online:
245+
/// <para></para>
246+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</a>
247+
/// </summary>
248+
public CatResponse<CatDatafeedsRecord> Datafeeds(ICatDatafeedsRequest request) => DoCat<ICatDatafeedsRequest, CatDatafeedsRequestParameters, CatDatafeedsRecord>(request);
249+
/// <summary>
250+
/// <c>GET</c> request to the <c>cat.ml_datafeeds</c> API, read more about this API online:
251+
/// <para></para>
252+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</a>
253+
/// </summary>
254+
public Task<CatResponse<CatDatafeedsRecord>> DatafeedsAsync(ICatDatafeedsRequest request, CancellationToken ct = default) => DoCatAsync<ICatDatafeedsRequest, CatDatafeedsRequestParameters, CatDatafeedsRecord>(request, ct);
255+
/// <summary>
232256
/// <c>GET</c> request to the <c>cat.ml_jobs</c> API, read more about this API online:
233257
/// <para></para>
234258
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html</a>

src/Nest/Requests.Cat.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,83 @@ public bool? Verbose
680680
}
681681
}
682682

683+
[InterfaceDataContract]
684+
public partial interface ICatDatafeedsRequest : IRequest<CatDatafeedsRequestParameters>
685+
{
686+
[IgnoreDataMember]
687+
Id DatafeedId
688+
{
689+
get;
690+
}
691+
}
692+
693+
///<summary>Request for Datafeeds <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html</para></summary>
694+
public partial class CatDatafeedsRequest : PlainRequestBase<CatDatafeedsRequestParameters>, ICatDatafeedsRequest
695+
{
696+
protected ICatDatafeedsRequest Self => this;
697+
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatDatafeeds;
698+
///<summary>/_cat/ml/datafeeds</summary>
699+
public CatDatafeedsRequest(): base()
700+
{
701+
}
702+
703+
///<summary>/_cat/ml/datafeeds/{datafeed_id}</summary>
704+
///<param name = "datafeedId">Optional, accepts null</param>
705+
public CatDatafeedsRequest(Id datafeedId): base(r => r.Optional("datafeed_id", datafeedId))
706+
{
707+
}
708+
709+
// values part of the url path
710+
[IgnoreDataMember]
711+
Id ICatDatafeedsRequest.DatafeedId => Self.RouteValues.Get<Id>("datafeed_id");
712+
// Request parameters
713+
///<summary>Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified)</summary>
714+
public bool? AllowNoDatafeeds
715+
{
716+
get => Q<bool? >("allow_no_datafeeds");
717+
set => Q("allow_no_datafeeds", value);
718+
}
719+
720+
///<summary>a short version of the Accept header, e.g. json, yaml</summary>
721+
public string Format
722+
{
723+
get => Q<string>("format");
724+
set
725+
{
726+
Q("format", value);
727+
SetAcceptHeader(value);
728+
}
729+
}
730+
731+
///<summary>Comma-separated list of column names to display</summary>
732+
public string[] Headers
733+
{
734+
get => Q<string[]>("h");
735+
set => Q("h", value);
736+
}
737+
738+
///<summary>Return help information</summary>
739+
public bool? Help
740+
{
741+
get => Q<bool? >("help");
742+
set => Q("help", value);
743+
}
744+
745+
///<summary>Comma-separated list of column names or column aliases to sort by</summary>
746+
public string[] SortByColumns
747+
{
748+
get => Q<string[]>("s");
749+
set => Q("s", value);
750+
}
751+
752+
///<summary>Verbose mode. Display column headers</summary>
753+
public bool? Verbose
754+
{
755+
get => Q<bool? >("v");
756+
set => Q("v", value);
757+
}
758+
}
759+
683760
[InterfaceDataContract]
684761
public partial interface ICatJobsRequest : IRequest<CatJobsRequestParameters>
685762
{

src/Nest/XPack/MachineLearning/Datafeed/DatafeedState.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@
44

55
namespace Nest
66
{
7+
/// <summary>
8+
/// The status of the datafeed
9+
/// </summary>
710
[StringEnum]
811
public enum DatafeedState
912
{
13+
/// <summary>
14+
/// The datafeed is actively receiving data.
15+
/// </summary>
1016
[EnumMember(Value = "started")]
1117
Started,
1218

19+
/// <summary>
20+
/// The datafeed is stopped and will not receive data until it is re-started.
21+
/// </summary>
1322
[EnumMember(Value = "stopped")]
1423
Stopped,
1524

25+
/// <summary>
26+
/// The datafeed has been requested to start but has not yet started.
27+
/// </summary>
1628
[EnumMember(Value = "starting")]
1729
Starting,
1830

31+
/// <summary>
32+
/// The datafeed has been requested to stop gracefully and is completing its final action.
33+
/// </summary>
1934
[EnumMember(Value = "stopping")]
2035
Stopping
2136
}

src/Nest/_Generated/ApiUrlsLookup.generated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static class ApiUrlsLookups
3232
internal static ApiUrls CatIndices = new ApiUrls(new[]{"_cat/indices", "_cat/indices/{index}"});
3333
internal static ApiUrls CatMaster = new ApiUrls(new[]{"_cat/master"});
3434
internal static ApiUrls CatMlDataFrameAnalytics = new ApiUrls(new[]{"_cat/ml/data_frame/analytics", "_cat/ml/data_frame/analytics/{id}"});
35-
internal static ApiUrls CatMlDatafeeds = new ApiUrls(new[]{"_cat/ml/datafeeds", "_cat/ml/datafeeds/{datafeed_id}"});
35+
internal static ApiUrls CatDatafeeds = new ApiUrls(new[]{"_cat/ml/datafeeds", "_cat/ml/datafeeds/{datafeed_id}"});
3636
internal static ApiUrls CatJobs = new ApiUrls(new[]{"_cat/ml/anomaly_detectors", "_cat/ml/anomaly_detectors/{job_id}"});
3737
internal static ApiUrls CatTrainedModels = new ApiUrls(new[]{"_cat/ml/trained_models", "_cat/ml/trained_models/{model_id}"});
3838
internal static ApiUrls CatNodeAttributes = new ApiUrls(new[]{"_cat/nodeattrs"});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Elastic.Xunit.XunitPlumbing;
2+
using Elasticsearch.Net;
3+
using Nest;
4+
using Tests.Core.Extensions;
5+
using Tests.Framework.EndpointTests.TestState;
6+
using Tests.XPack.MachineLearning;
7+
8+
namespace Tests.Cat.CatDatafeeds
9+
{
10+
[SkipVersion("<7.7.0", "Introduced in 7.7.0")]
11+
public class CatDatafeedsApiTests
12+
: MachineLearningIntegrationTestBase<CatResponse<CatDatafeedsRecord>, ICatDatafeedsRequest, CatDatafeedsDescriptor,
13+
CatDatafeedsRequest>
14+
{
15+
public CatDatafeedsApiTests(MachineLearningCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
16+
17+
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
18+
{
19+
foreach (var callUniqueValue in values)
20+
{
21+
PutJob(client, callUniqueValue.Value);
22+
OpenJob(client, callUniqueValue.Value);
23+
PutDatafeed(client, callUniqueValue.Value);
24+
}
25+
}
26+
27+
protected override bool ExpectIsValid => true;
28+
protected override int ExpectStatusCode => 200;
29+
protected override HttpMethod HttpMethod => HttpMethod.GET;
30+
protected override string UrlPath => "/_cat/ml/datafeeds";
31+
32+
protected override LazyResponses ClientUsage() => Calls(
33+
(client, f) => client.Cat.Datafeeds(),
34+
(client, f) => client.Cat.DatafeedsAsync(),
35+
(client, r) => client.Cat.Datafeeds(r),
36+
(client, r) => client.Cat.DatafeedsAsync(r)
37+
);
38+
39+
protected override void ExpectResponse(CatResponse<CatDatafeedsRecord> response) => response.ShouldBeValid();
40+
}
41+
}

0 commit comments

Comments
 (0)