Skip to content

Commit 220b2dc

Browse files
committed
Delete by query rethrottle API (#3595)
* download specs from v6.6.2 tag * Delete by Query rethrottle API * exclude DeleteByQueryRethrottle API from naming conventions
1 parent 0b8fb97 commit 220b2dc

File tree

18 files changed

+1024
-3442
lines changed

18 files changed

+1024
-3442
lines changed

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class ApiGenerator
2929
// these API's are new and need to be mapped
3030
"xpack.ml.delete_forecast.json",
3131
"xpack.ml.find_file_structure.json",
32-
"delete_by_query_rethrottle.json",
3332

3433
"xpack.ml.update_filter.json",
3534
"xpack.security.delete_privileges.json",

src/CodeGeneration/ApiGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private static void Main(string[] args)
2222

2323
if (redownloadCoreSpecification)
2424
{
25-
Console.Write("Branch to download specification from (default master): ");
25+
Console.Write($"Branch to download specification from (default {downloadBranch}): ");
2626
var readBranch = Console.ReadLine()?.Trim();
2727
if (!string.IsNullOrEmpty(readBranch)) downloadBranch = readBranch;
2828
}

src/CodeGeneration/ApiGenerator/RestSpecification/Core/root.html

Lines changed: 717 additions & 3436 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.5.3
1+
v6.6.2

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,13 @@ public partial class DeleteByQueryRequestParameters : RequestParameters<DeleteBy
740740
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
741741
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
742742
}
743+
///<summary>Request options for DeleteByQueryRethrottle<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
744+
public partial class DeleteByQueryRethrottleRequestParameters : RequestParameters<DeleteByQueryRethrottleRequestParameters>
745+
{
746+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
747+
///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
748+
public long? RequestsPerSecond { get => Q<long?>("requests_per_second"); set => Q("requests_per_second", value); }
749+
}
743750
///<summary>Request options for DeleteScript<pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</pre></summary>
744751
public partial class DeleteScriptRequestParameters : RequestParameters<DeleteScriptRequestParameters>
745752
{

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,16 @@ public TResponse DeleteByQuery<TResponse>(string index, string type, PostData bo
636636
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
637637
public Task<TResponse> DeleteByQueryAsync<TResponse>(string index, string type, PostData body, DeleteByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
638638
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"{index.NotNull("index")}/{type.NotNull("type")}/_delete_by_query"), ctx, body, _params(requestParameters));
639+
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
640+
///<param name="task_id">The task id to rethrottle</param>
641+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
642+
public TResponse DeleteByQueryRethrottle<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null)
643+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(POST, Url($"_delete_by_query/{task_id.NotNull("task_id")}/_rethrottle"), null, _params(requestParameters));
644+
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
645+
///<param name="task_id">The task id to rethrottle</param>
646+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
647+
public Task<TResponse> DeleteByQueryRethrottleAsync<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
648+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_delete_by_query/{task_id.NotNull("task_id")}/_rethrottle"), ctx, null, _params(requestParameters));
639649
///<summary>DELETE on /_scripts/{id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</para></summary>
640650
///<param name="id">Script ID</param>
641651
///<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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@ public partial interface IElasticLowLevelClient
508508
///<param name="body">The search definition using the Query DSL</param>
509509
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
510510
Task<TResponse> DeleteByQueryAsync<TResponse>(string index, string type, PostData body, DeleteByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
511+
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
512+
///<param name="task_id">The task id to rethrottle</param>
513+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
514+
TResponse DeleteByQueryRethrottle<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
515+
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
516+
///<param name="task_id">The task id to rethrottle</param>
517+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
518+
Task<TResponse> DeleteByQueryRethrottleAsync<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
511519
///<summary>DELETE on /_scripts/{id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</para></summary>
512520
///<param name="id">Script ID</param>
513521
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>

src/Elasticsearch.sln.DotSettings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,5 @@
479479
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/Name/@EntryValue">Hack</s:String>
480480
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/Pattern/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;HACK)(\W|$)(.*)</s:String>
481481
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/TodoIconStyle/@EntryValue">Warning</s:String>
482-
<s:Boolean x:Key="/Default/UserDictionary/Words/=/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
482+
<s:Boolean x:Key="/Default/UserDictionary/Words/=/@EntryIndexedValue">True</s:Boolean>
483+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rethrottle/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public class ListTasksResponse : ResponseBase, IListTasksResponse
1818
{
1919
public override bool IsValid => base.IsValid && !NodeFailures.HasAny();
2020
public IReadOnlyCollection<ErrorCause> NodeFailures { get; internal set; } = EmptyReadOnly<ErrorCause>.Collection;
21-
2221
public IReadOnlyDictionary<string, TaskExecutingNode> Nodes { get; internal set; } = EmptyReadOnly<string, TaskExecutingNode>.Dictionary;
2322
}
2423

24+
/// <summary>
25+
/// A node executing a task
26+
/// </summary>
2527
public class TaskExecutingNode
2628
{
2729
[JsonProperty("attributes")]
@@ -48,6 +50,9 @@ public class TaskExecutingNode
4850
public string TransportAddress { get; internal set; }
4951
}
5052

53+
/// <summary>
54+
/// The state of the task
55+
/// </summary>
5156
public class TaskState
5257
{
5358
[JsonProperty("action")]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace Nest
5+
{
6+
/// <summary>
7+
/// Rethrottles a running delete by query
8+
/// </summary>
9+
public partial interface IDeleteByQueryRethrottleRequest
10+
{
11+
}
12+
13+
/// <inheritdoc cref="IDeleteByQueryRethrottleRequest" />
14+
public partial class DeleteByQueryRethrottleRequest : IDeleteByQueryRethrottleRequest
15+
{
16+
17+
}
18+
19+
/// <inheritdoc cref="IDeleteByQueryRethrottleRequest" />
20+
public partial class DeleteByQueryRethrottleDescriptor : IDeleteByQueryRethrottleRequest
21+
{
22+
}
23+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/// Rethrottles a running delete by query. Rethrottling that speeds up the query takes effect immediately
12+
/// but rethrotting that slows down the query will take effect after completing the current batch. This prevents scroll timeouts.
13+
/// <para> </para>
14+
/// <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-rethrottle">https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-rethrottle</a>
15+
/// </summary>
16+
IListTasksResponse DeleteByQueryRethrottle(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null);
17+
18+
/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
19+
IListTasksResponse DeleteByQueryRethrottle(IDeleteByQueryRethrottleRequest request);
20+
21+
/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
22+
Task<IListTasksResponse> DeleteByQueryRethrottleAsync(TaskId taskId,
23+
Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null,
24+
CancellationToken cancellationToken = default(CancellationToken)
25+
);
26+
27+
/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
28+
Task<IListTasksResponse> DeleteByQueryRethrottleAsync(IDeleteByQueryRethrottleRequest request,
29+
CancellationToken cancellationToken = default(CancellationToken)
30+
);
31+
}
32+
33+
public partial class ElasticClient
34+
{
35+
/// <inheritdoc />
36+
public IListTasksResponse DeleteByQueryRethrottle(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null) =>
37+
DeleteByQueryRethrottle(selector.InvokeOrDefault(new DeleteByQueryRethrottleDescriptor(taskId)));
38+
39+
/// <inheritdoc />
40+
public IListTasksResponse DeleteByQueryRethrottle(IDeleteByQueryRethrottleRequest request) =>
41+
Dispatcher.Dispatch<IDeleteByQueryRethrottleRequest, DeleteByQueryRethrottleRequestParameters, ListTasksResponse>(
42+
request,
43+
(p, d) => LowLevelDispatch.DeleteByQueryRethrottleDispatch<ListTasksResponse>(p)
44+
);
45+
46+
/// <inheritdoc />
47+
public Task<IListTasksResponse> DeleteByQueryRethrottleAsync(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null,
48+
CancellationToken cancellationToken = default(CancellationToken)
49+
) =>
50+
DeleteByQueryRethrottleAsync(selector.InvokeOrDefault(new DeleteByQueryRethrottleDescriptor(taskId)), cancellationToken);
51+
52+
/// <inheritdoc />
53+
public Task<IListTasksResponse> DeleteByQueryRethrottleAsync(IDeleteByQueryRethrottleRequest request,
54+
CancellationToken cancellationToken = default(CancellationToken)
55+
) =>
56+
Dispatcher.DispatchAsync<IDeleteByQueryRethrottleRequest, DeleteByQueryRethrottleRequestParameters, ListTasksResponse, IListTasksResponse>(
57+
request,
58+
cancellationToken,
59+
(p, d, c) => LowLevelDispatch.DeleteByQueryRethrottleDispatchAsync<ListTasksResponse>(p, c)
60+
);
61+
}
62+
}

src/Nest/_Generated/_Descriptors.generated.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,20 @@ public DeleteByQueryDescriptor(Indices index) : base(r=>r.Required("index", inde
11081108
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
11091109
public DeleteByQueryDescriptor<T> Slices(long? slices) => Qs("slices", slices);
11101110
}
1111+
///<summary>descriptor for DeleteByQueryRethrottle <pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
1112+
public partial class DeleteByQueryRethrottleDescriptor : RequestDescriptorBase<DeleteByQueryRethrottleDescriptor,DeleteByQueryRethrottleRequestParameters, IDeleteByQueryRethrottleRequest>, IDeleteByQueryRethrottleRequest
1113+
{
1114+
/// <summary>/_delete_by_query/{task_id}/_rethrottle</summary>
1115+
///<param name="task_id"> this parameter is required</param>
1116+
public DeleteByQueryRethrottleDescriptor(TaskId task_id) : base(r=>r.Required("task_id", task_id)){}
1117+
// values part of the url path
1118+
TaskId IDeleteByQueryRethrottleRequest.TaskId => Self.RouteValues.Get<TaskId>("task_id");
1119+
1120+
// Request parameters
1121+
1122+
///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
1123+
public DeleteByQueryRethrottleDescriptor RequestsPerSecond(long? requestsPerSecond) => Qs("requests_per_second", requestsPerSecond);
1124+
}
11111125
///<summary>descriptor for DeleteScript <pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</pre></summary>
11121126
public partial class DeleteScriptDescriptor : RequestDescriptorBase<DeleteScriptDescriptor,DeleteScriptRequestParameters, IDeleteScriptRequest>, IDeleteScriptRequest
11131127
{

src/Nest/_Generated/_LowLevelDispatch.generated.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,28 @@ internal partial class LowLevelDispatch
788788
throw InvalidDispatch("DeleteByQuery", p, new [] { POST }, "/{index}/_delete_by_query", "/{index}/{type}/_delete_by_query");
789789
}
790790

791+
internal TResponse DeleteByQueryRethrottleDispatch<TResponse>(IRequest<DeleteByQueryRethrottleRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
792+
{
793+
switch(p.HttpMethod)
794+
{
795+
case POST:
796+
if (AllSetNoFallback(p.RouteValues.TaskId)) return _lowLevel.DeleteByQueryRethrottle<TResponse>(p.RouteValues.TaskId,p.RequestParameters);
797+
break;
798+
}
799+
throw InvalidDispatch("DeleteByQueryRethrottle", p, new [] { POST }, "/_delete_by_query/{task_id}/_rethrottle");
800+
}
801+
802+
internal Task<TResponse> DeleteByQueryRethrottleDispatchAsync<TResponse>(IRequest<DeleteByQueryRethrottleRequestParameters> p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new()
803+
{
804+
switch(p.HttpMethod)
805+
{
806+
case POST:
807+
if (AllSetNoFallback(p.RouteValues.TaskId)) return _lowLevel.DeleteByQueryRethrottleAsync<TResponse>(p.RouteValues.TaskId,p.RequestParameters,ct);
808+
break;
809+
}
810+
throw InvalidDispatch("DeleteByQueryRethrottle", p, new [] { POST }, "/_delete_by_query/{task_id}/_rethrottle");
811+
}
812+
791813
internal TResponse DeleteScriptDispatch<TResponse>(IRequest<DeleteScriptRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
792814
{
793815
switch(p.HttpMethod)

src/Nest/_Generated/_Requests.generated.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,25 @@ public DeleteByQueryRequest(Indices index, Types type) : base(r=>r.Required("ind
17861786
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
17871787
}
17881788
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
1789+
public partial interface IDeleteByQueryRethrottleRequest : IRequest<DeleteByQueryRethrottleRequestParameters>
1790+
{
1791+
TaskId TaskId { get; }
1792+
}
1793+
///<summary>Request parameters for DeleteByQueryRethrottle <pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
1794+
public partial class DeleteByQueryRethrottleRequest : PlainRequestBase<DeleteByQueryRethrottleRequestParameters>, IDeleteByQueryRethrottleRequest
1795+
{
1796+
protected IDeleteByQueryRethrottleRequest Self => this;
1797+
///<summary>/_delete_by_query/{task_id}/_rethrottle</summary>
1798+
///<param name="task_id">this parameter is required</param>
1799+
public DeleteByQueryRethrottleRequest(TaskId task_id) : base(r=>r.Required("task_id", task_id)){}
1800+
// values part of the url path
1801+
TaskId IDeleteByQueryRethrottleRequest.TaskId => Self.RouteValues.Get<TaskId>("task_id");
1802+
1803+
// Request parameters
1804+
///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
1805+
public long? RequestsPerSecond { get => Q<long?>("requests_per_second"); set => Q("requests_per_second", value); }
1806+
}
1807+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
17891808
public partial interface IDeleteCalendarEventRequest : IRequest<DeleteCalendarEventRequestParameters>
17901809
{
17911810
Id CalendarId { get; }

src/Tests/Tests.Configuration/tests.default.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# tracked by git).
66

77
# mode either u (unit test), i (integration test) or m (mixed mode)
8-
mode: i
8+
mode: m
9+
910
# the elasticsearch version that should be started
1011
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
1112
elasticsearch_version: 6.6.2

src/Tests/Tests/CodeStandards/NamingConventions.doc.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public void ParityBetweenRequestsAndResponses()
125125
typeof(RenderSearchTemplateRequest),
126126
typeof(MultiSearchTemplateRequest),
127127
typeof(CreateRequest<>),
128+
typeof(DeleteByQueryRethrottleRequest), // uses ListTasksResponse
128129
typeof(UpdateByQueryRethrottleRequest) // uses ListTasksResponse
129130
};
130131

0 commit comments

Comments
 (0)