Skip to content

Commit 698d632

Browse files
author
Stuart Cam
authored
Implement ML Info Api (#3571)
1 parent 4b860cb commit 698d632

File tree

12 files changed

+262
-1
lines changed

12 files changed

+262
-1
lines changed

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class ApiGenerator
2727
"rank_eval.json",
2828

2929
// these API's are new and need to be mapped
30-
"xpack.ml.info.json",
3130
"xpack.ml.delete_forecast.json",
3231
"xpack.ml.find_file_structure.json",
3332
"delete_by_query_rethrottle.json",

src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,11 @@ public partial class GetAnomalyRecordsRequestParameters : RequestParameters<GetA
24812481
{
24822482
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
24832483
}
2484+
///<summary>Request options for XpackMlInfo<pre></pre></summary>
2485+
public partial class MachineLearningInfoRequestParameters : RequestParameters<MachineLearningInfoRequestParameters>
2486+
{
2487+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2488+
}
24842489
///<summary>Request options for XpackMlOpenJob<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html</pre></summary>
24852490
public partial class OpenJobRequestParameters : RequestParameters<OpenJobRequestParameters>
24862491
{

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,14 @@ public TResponse XpackMlGetRecords<TResponse>(string job_id, PostData body, GetA
35663566
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
35673567
public Task<TResponse> XpackMlGetRecordsAsync<TResponse>(string job_id, PostData body, GetAnomalyRecordsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
35683568
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_xpack/ml/anomaly_detectors/{job_id.NotNull("job_id")}/results/records"), ctx, body, _params(requestParameters));
3569+
///<summary>GET on /_xpack/ml/info <para></para></summary>
3570+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
3571+
public TResponse XpackMlInfo<TResponse>(MachineLearningInfoRequestParameters requestParameters = null)
3572+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(GET, Url($"_xpack/ml/info"), null, _params(requestParameters));
3573+
///<summary>GET on /_xpack/ml/info <para></para></summary>
3574+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
3575+
public Task<TResponse> XpackMlInfoAsync<TResponse>(MachineLearningInfoRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
3576+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(GET, Url($"_xpack/ml/info"), ctx, null, _params(requestParameters));
35693577
///<summary>POST on /_xpack/ml/anomaly_detectors/{job_id}/_open <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html</para></summary>
35703578
///<param name="job_id">The ID of the job to open</param>
35713579
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,6 +2888,12 @@ public partial interface IElasticLowLevelClient
28882888
///<param name="body">Record selection criteria</param>
28892889
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
28902890
Task<TResponse> XpackMlGetRecordsAsync<TResponse>(string job_id, PostData body, GetAnomalyRecordsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2891+
///<summary>GET on /_xpack/ml/info <para></para></summary>
2892+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2893+
TResponse XpackMlInfo<TResponse>(MachineLearningInfoRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2894+
///<summary>GET on /_xpack/ml/info <para></para></summary>
2895+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2896+
Task<TResponse> XpackMlInfoAsync<TResponse>(MachineLearningInfoRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
28912897
///<summary>POST on /_xpack/ml/anomaly_detectors/{job_id}/_open <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html</para></summary>
28922898
///<param name="job_id">The ID of the job to open</param>
28932899
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using Elasticsearch.Net;
5+
6+
namespace Nest
7+
{
8+
public partial interface IElasticClient
9+
{
10+
/// <summary>
11+
/// Retrieves machine learning job results for one or more categories.
12+
/// </summary>
13+
IMachineLearningInfoResponse MachineLearningInfo(Func<MachineLearningInfoDescriptor, IMachineLearningInfoRequest> selector = null);
14+
15+
/// <inheritdoc />
16+
IMachineLearningInfoResponse MachineLearningInfo(IMachineLearningInfoRequest request);
17+
18+
/// <inheritdoc />
19+
Task<IMachineLearningInfoResponse> MachineLearningInfoAsync(Func<MachineLearningInfoDescriptor, IMachineLearningInfoRequest> selector = null,
20+
CancellationToken cancellationToken = default(CancellationToken)
21+
);
22+
23+
/// <inheritdoc />
24+
Task<IMachineLearningInfoResponse> MachineLearningInfoAsync(IMachineLearningInfoRequest request,
25+
CancellationToken cancellationToken = default(CancellationToken)
26+
);
27+
}
28+
29+
public partial class ElasticClient
30+
{
31+
/// <inheritdoc />
32+
public IMachineLearningInfoResponse MachineLearningInfo(Func<MachineLearningInfoDescriptor, IMachineLearningInfoRequest> selector = null) =>
33+
MachineLearningInfo(selector.InvokeOrDefault(new MachineLearningInfoDescriptor()));
34+
35+
/// <inheritdoc />
36+
public IMachineLearningInfoResponse MachineLearningInfo(IMachineLearningInfoRequest request) =>
37+
Dispatcher.Dispatch<IMachineLearningInfoRequest, MachineLearningInfoRequestParameters, MachineLearningInfoResponse>(
38+
request,
39+
(p, d) => LowLevelDispatch.XpackMlInfoDispatch<MachineLearningInfoResponse>(p)
40+
);
41+
42+
/// <inheritdoc />
43+
public Task<IMachineLearningInfoResponse> MachineLearningInfoAsync(Func<MachineLearningInfoDescriptor, IMachineLearningInfoRequest> selector = null,
44+
CancellationToken cancellationToken = default(CancellationToken)
45+
) =>
46+
MachineLearningInfoAsync(selector.InvokeOrDefault(new MachineLearningInfoDescriptor()), cancellationToken);
47+
48+
/// <inheritdoc />
49+
public Task<IMachineLearningInfoResponse> MachineLearningInfoAsync(IMachineLearningInfoRequest request,
50+
CancellationToken cancellationToken = default(CancellationToken)
51+
) =>
52+
Dispatcher.DispatchAsync<IMachineLearningInfoRequest, MachineLearningInfoRequestParameters, MachineLearningInfoResponse, IMachineLearningInfoResponse>(
53+
request,
54+
cancellationToken,
55+
(p, d, c) => LowLevelDispatch.XpackMlInfoDispatchAsync<MachineLearningInfoResponse>(p, c)
56+
);
57+
}
58+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace Nest
5+
{
6+
/// <summary>
7+
/// Retrieve job results for one or more categories.
8+
/// </summary>
9+
public partial interface IMachineLearningInfoRequest { }
10+
11+
/// <inheritdoc />
12+
public partial class MachineLearningInfoRequest { }
13+
14+
/// <inheritdoc />
15+
[DescriptorFor("XpackMlInfo")]
16+
public partial class MachineLearningInfoDescriptor { }
17+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Nest
4+
{
5+
public interface IMachineLearningInfoResponse : IResponse
6+
{
7+
[JsonProperty("defaults")]
8+
Defaults Defaults { get; }
9+
10+
[JsonProperty("limits")]
11+
Limits Limits { get; }
12+
13+
[JsonProperty("upgrade_mode")]
14+
bool? UpgradeMode { get; }
15+
}
16+
17+
public class MachineLearningInfoResponse : ResponseBase, IMachineLearningInfoResponse
18+
{
19+
[JsonProperty("defaults")]
20+
public Defaults Defaults { get; internal set; }
21+
22+
[JsonProperty("limits")]
23+
public Limits Limits { get; internal set; }
24+
25+
[JsonProperty("upgrade_mode")]
26+
public bool? UpgradeMode { get; internal set; }
27+
}
28+
29+
public class Defaults
30+
{
31+
[JsonProperty("anomaly_detectors")]
32+
public AnomalyDetectors AnomalyDetectors { get; internal set; }
33+
34+
[JsonProperty("datafeeds")]
35+
public Datafeeds Datafeeds { get; internal set; }
36+
}
37+
38+
public class AnomalyDetectors
39+
{
40+
[JsonProperty("model_memory_limit")]
41+
public string ModelMemoryLimit { get; internal set; }
42+
43+
[JsonProperty("categorization_examples_limit")]
44+
public int CategorizationExamplesLimit { get; internal set; }
45+
46+
[JsonProperty("model_snapshot_retention_days")]
47+
public int ModelSnapshotRetentionDays { get; internal set; }
48+
}
49+
50+
public class Datafeeds
51+
{
52+
[JsonProperty("scroll_size")]
53+
public int ScrollSize { get; internal set; }
54+
}
55+
56+
public class Limits
57+
{
58+
[JsonProperty("max_model_memory_limit")]
59+
public string MaxModelMemoryLimit { get; internal set; }
60+
}
61+
}

src/Nest/_Generated/_Descriptors.generated.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4435,6 +4435,14 @@ public GetAnomalyRecordsDescriptor(Id job_id) : base(r=>r.Required("job_id", job
44354435

44364436
// Request parameters
44374437

4438+
}
4439+
///<summary>descriptor for XpackMlInfo <pre></pre></summary>
4440+
public partial class MachineLearningInfoDescriptor : RequestDescriptorBase<MachineLearningInfoDescriptor,MachineLearningInfoRequestParameters, IMachineLearningInfoRequest>, IMachineLearningInfoRequest
4441+
{
4442+
// values part of the url path
4443+
4444+
// Request parameters
4445+
44384446
}
44394447
///<summary>descriptor for XpackMlOpenJob <pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html</pre></summary>
44404448
public partial class OpenJobDescriptor : RequestDescriptorBase<OpenJobDescriptor,OpenJobRequestParameters, IOpenJobRequest>, IOpenJobRequest

src/Nest/_Generated/_LowLevelDispatch.generated.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,26 @@ internal partial class LowLevelDispatch
38643864
throw InvalidDispatch("XpackMlGetRecords", p, new [] { GET, POST }, "/_xpack/ml/anomaly_detectors/{job_id}/results/records");
38653865
}
38663866

3867+
internal TResponse XpackMlInfoDispatch<TResponse>(IRequest<MachineLearningInfoRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
3868+
{
3869+
switch(p.HttpMethod)
3870+
{
3871+
case GET:
3872+
return _lowLevel.XpackMlInfo<TResponse>(p.RequestParameters);
3873+
}
3874+
throw InvalidDispatch("XpackMlInfo", p, new [] { GET }, "/_xpack/ml/info");
3875+
}
3876+
3877+
internal Task<TResponse> XpackMlInfoDispatchAsync<TResponse>(IRequest<MachineLearningInfoRequestParameters> p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new()
3878+
{
3879+
switch(p.HttpMethod)
3880+
{
3881+
case GET:
3882+
return _lowLevel.XpackMlInfoAsync<TResponse>(p.RequestParameters,ct);
3883+
}
3884+
throw InvalidDispatch("XpackMlInfo", p, new [] { GET }, "/_xpack/ml/info");
3885+
}
3886+
38673887
internal TResponse XpackMlOpenJobDispatch<TResponse>(IRequest<OpenJobRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
38683888
{
38693889
switch(p.HttpMethod)

src/Nest/_Generated/_Requests.generated.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,6 +3893,18 @@ public partial class ListTasksRequest : PlainRequestBase<ListTasksRequestParamet
38933893
public string ParentNode { get => Q<string>("parent_node"); set => Q("parent_node", value); }
38943894
}
38953895
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
3896+
public partial interface IMachineLearningInfoRequest : IRequest<MachineLearningInfoRequestParameters>
3897+
{
3898+
}
3899+
///<summary>Request parameters for XpackMlInfo <pre></pre></summary>
3900+
public partial class MachineLearningInfoRequest : PlainRequestBase<MachineLearningInfoRequestParameters>, IMachineLearningInfoRequest
3901+
{
3902+
protected IMachineLearningInfoRequest Self => this;
3903+
// values part of the url path
3904+
3905+
// Request parameters
3906+
}
3907+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
38963908
public partial interface IMigrationAssistanceRequest : IRequest<MigrationAssistanceRequestParameters>
38973909
{
38983910
Indices Index { get; }

0 commit comments

Comments
 (0)