Skip to content

Commit 4cb05c0

Browse files
Mpdreamzrusscam
authored andcommitted
Add support for Rollup APIs (#3448)
This commit adds support for the Rollup APIs: - CreateRollupJob - GetRollupJob - DeleteRollupJob - StartRollupJob - StopRollupJob - GetRollupCapabilities - RollupSearch
1 parent f7712ff commit 4cb05c0

File tree

63 files changed

+2643
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2643
-145
lines changed

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,14 @@ public static void Generate(string downloadBranch, params string[] folders)
7373
"xpack.ml.put_calendar_job.json",
7474
"xpack.ml.get_calendar_job.json",
7575

76-
"xpack.rollup.delete_job.json",
77-
"xpack.rollup.get_jobs.json",
78-
"xpack.rollup.get_rollup_caps.json",
79-
"xpack.rollup.put_job.json",
80-
"xpack.rollup.rollup_search.json",
81-
"xpack.rollup.start_job.json",
82-
"xpack.rollup.stop_job.json",
83-
76+
"xpack.sql.clear_cursor.json",
77+
"xpack.sql.query.json",
78+
"xpack.sql.translate.json",
8479
"xpack.ssl.certificates.json",
8580

8681
// 6.4 new API's
8782

8883
"xpack.ml.update_filter.json",
89-
"xpack.rollup.get_rollup_index_caps.json",
9084
"xpack.security.delete_privileges.json",
9185
"xpack.security.get_privileges.json",
9286
"xpack.security.has_privileges.json",
@@ -171,10 +165,20 @@ private static void PatchOfficialSpec(JObject original, string jsonFile)
171165

172166
var patchedJson = JObject.Parse(File.ReadAllText(patchFile));
173167

168+
var pathsOverride = patchedJson.SelectToken("*.url.paths");
169+
174170
original.Merge(patchedJson, new JsonMergeSettings
175171
{
176172
MergeArrayHandling = MergeArrayHandling.Union
177173
});
174+
175+
if (pathsOverride != null)
176+
{
177+
original.SelectToken("*.url.paths").Replace(pathsOverride);
178+
}
179+
180+
181+
178182
}
179183

180184
private static Dictionary<string, ApiQueryParameters> CreateCommonApiQueryParameters(string jsonFile)

src/CodeGeneration/ApiGenerator/Domain/ApiUrl.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ public class ApiUrl
1515

1616
public IEnumerable<string> Paths
1717
{
18-
get
19-
{
20-
return _paths?.Where(p => !BlackListRouteValues.Any(p.Contains))
21-
.ToList() ?? _paths;
22-
}
23-
set { _paths = value; }
18+
get => _paths?.Where(p => !BlackListRouteValues.Any(p.Contains))
19+
.ToList() ?? _paths;
20+
set => _paths = this.EnsureBackslash(value);
2421
}
2522

23+
public IList<string> EnsureBackslash(IEnumerable<string> paths) =>
24+
paths?.Select(p => p.StartsWith("/") ? p : $"/{p}").ToList();
25+
2626
public IDictionary<string, ApiUrlPart> Parts { get; set; }
2727
public IDictionary<string, ApiQueryParameters> Params { get; set; }
2828

2929
}
30-
}
30+
}

src/CodeGeneration/ApiGenerator/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ static void Main(string[] args)
4141
if (redownloadCoreSpecification)
4242
RestSpecDownloader.Download(downloadBranch);
4343

44-
ApiGenerator.Generate(downloadBranch, "Core", "Graph", "License", "Security", "Watcher", "Info",
45-
"MachineLearning", "Migration", "Sql");
44+
ApiGenerator.Generate(downloadBranch, "Core", "Graph", "License", "Security", "Watcher", "Info", "MachineLearning", "Migration", "Sql", "Rollup");
4645
}
4746
}
4847
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"xpack.rollup.get_rollup_caps": {
3+
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-get-rollup-caps.html",
4+
"url": {
5+
"path": "/_xpack/rollup/data/{index}",
6+
"paths": [ "/_xpack/rollup/data/{index}", "/_xpack/rollup/data/" ],
7+
"parts": {
8+
"index": {
9+
"type": "list",
10+
"required": false,
11+
"description": " Index, indices or index-pattern to return rollup capabilities for. _all may be used to fetch rollup capabilities from all job"
12+
}
13+
}
14+
}
15+
}
16+
}

src/CodeGeneration/ApiGenerator/RestSpecification/XPack/Rollup/xpack.rollup.get_rollup_index_caps.json

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"xpack.rollup.rollup_search": {
3+
"url": {
4+
"parts": {
5+
"index": {
6+
"type": "list",
7+
"required": true,
8+
"description": "The index or index-pattern (containing rollup or regular data) that should be searched"
9+
}
10+
}
11+
}
12+
}
13+
}

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,41 @@ public partial class MigrationUpgradeRequestParameters : RequestParameters<Migra
24332433
///<summary>Should the request block until the upgrade operation is completed</summary>
24342434
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
24352435
}
2436+
///<summary>Request options for XpackRollupDeleteJob<pre></pre></summary>
2437+
public partial class DeleteRollupJobRequestParameters : RequestParameters<DeleteRollupJobRequestParameters>
2438+
{
2439+
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
2440+
}
2441+
///<summary>Request options for XpackRollupGetJobs<pre></pre></summary>
2442+
public partial class GetRollupJobRequestParameters : RequestParameters<GetRollupJobRequestParameters>
2443+
{
2444+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2445+
}
2446+
///<summary>Request options for XpackRollupGetRollupCaps<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-get-rollup-caps.html</pre></summary>
2447+
public partial class GetRollupCapabilitiesRequestParameters : RequestParameters<GetRollupCapabilitiesRequestParameters>
2448+
{
2449+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2450+
}
2451+
///<summary>Request options for XpackRollupPutJob<pre></pre></summary>
2452+
public partial class CreateRollupJobRequestParameters : RequestParameters<CreateRollupJobRequestParameters>
2453+
{
2454+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
2455+
}
2456+
///<summary>Request options for XpackRollupRollupSearch<pre></pre></summary>
2457+
public partial class RollupSearchRequestParameters : RequestParameters<RollupSearchRequestParameters>
2458+
{
2459+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2460+
}
2461+
///<summary>Request options for XpackRollupStartJob<pre></pre></summary>
2462+
public partial class StartRollupJobRequestParameters : RequestParameters<StartRollupJobRequestParameters>
2463+
{
2464+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2465+
}
2466+
///<summary>Request options for XpackRollupStopJob<pre></pre></summary>
2467+
public partial class StopRollupJobRequestParameters : RequestParameters<StopRollupJobRequestParameters>
2468+
{
2469+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2470+
}
24362471
///<summary>Request options for XpackSecurityAuthenticate<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html</pre></summary>
24372472
public partial class AuthenticateRequestParameters : RequestParameters<AuthenticateRequestParameters>
24382473
{

0 commit comments

Comments
 (0)