Skip to content

Commit a7b71bd

Browse files
committed
add support for the reload secure settings API (#3536)
1 parent a99f504 commit a7b71bd

File tree

12 files changed

+266
-1
lines changed

12 files changed

+266
-1
lines changed

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class ApiGenerator
5151
"xpack.security.put_privilege.json",
5252
"xpack.security.put_privileges.json",
5353
"xpack.rollup.get_rollup_index_caps.json",
54-
"nodes.reload_secure_settings.json"
5554
};
5655

5756
public static void Generate(string downloadBranch, params string[] folders)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,13 @@ public partial class NodesInfoRequestParameters : RequestParameters<NodesInfoReq
16951695
///<summary>Explicit operation timeout</summary>
16961696
public TimeSpan Timeout { get => Q<TimeSpan>("timeout"); set => Q("timeout", value); }
16971697
}
1698+
///<summary>Request options for NodesReloadSecureSettingsForAll<pre>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</pre></summary>
1699+
public partial class ReloadSecureSettingsRequestParameters : RequestParameters<ReloadSecureSettingsRequestParameters>
1700+
{
1701+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
1702+
///<summary>Explicit operation timeout</summary>
1703+
public TimeSpan Timeout { get => Q<TimeSpan>("timeout"); set => Q("timeout", value); }
1704+
}
16981705
///<summary>Request options for NodesStatsForAll<pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html</pre></summary>
16991706
public partial class NodesStatsRequestParameters : RequestParameters<NodesStatsRequestParameters>
17001707
{

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,24 @@ public TResponse NodesInfo<TResponse>(string node_id, string metric, NodesInfoRe
21902190
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
21912191
public Task<TResponse> NodesInfoAsync<TResponse>(string node_id, string metric, NodesInfoRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
21922192
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(GET, Url($"_nodes/{node_id.NotNull("node_id")}/{metric.NotNull("metric")}"), ctx, null, _params(requestParameters));
2193+
///<summary>POST on /_nodes/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
2194+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2195+
public TResponse NodesReloadSecureSettingsForAll<TResponse>(ReloadSecureSettingsRequestParameters requestParameters = null)
2196+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(POST, Url($"_nodes/reload_secure_settings"), null, _params(requestParameters));
2197+
///<summary>POST on /_nodes/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
2198+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2199+
public Task<TResponse> NodesReloadSecureSettingsForAllAsync<TResponse>(ReloadSecureSettingsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
2200+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_nodes/reload_secure_settings"), ctx, null, _params(requestParameters));
2201+
///<summary>POST on /_nodes/{node_id}/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
2202+
///<param name="node_id">A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.</param>
2203+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2204+
public TResponse NodesReloadSecureSettings<TResponse>(string node_id, ReloadSecureSettingsRequestParameters requestParameters = null)
2205+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(POST, Url($"_nodes/{node_id.NotNull("node_id")}/reload_secure_settings"), null, _params(requestParameters));
2206+
///<summary>POST on /_nodes/{node_id}/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
2207+
///<param name="node_id">A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.</param>
2208+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2209+
public Task<TResponse> NodesReloadSecureSettingsAsync<TResponse>(string node_id, ReloadSecureSettingsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
2210+
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_nodes/{node_id.NotNull("node_id")}/reload_secure_settings"), ctx, null, _params(requestParameters));
21932211
///<summary>GET on /_nodes/stats <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html</para></summary>
21942212
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
21952213
public TResponse NodesStatsForAll<TResponse>(NodesStatsRequestParameters requestParameters = null)

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,20 @@ public partial interface IElasticLowLevelClient
17721772
///<param name="metric">A comma-separated list of metrics you wish returned. Leave empty to return all.</param>
17731773
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
17741774
Task<TResponse> NodesInfoAsync<TResponse>(string node_id, string metric, NodesInfoRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
1775+
///<summary>POST on /_nodes/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
1776+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1777+
TResponse NodesReloadSecureSettingsForAll<TResponse>(ReloadSecureSettingsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
1778+
///<summary>POST on /_nodes/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
1779+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1780+
Task<TResponse> NodesReloadSecureSettingsForAllAsync<TResponse>(ReloadSecureSettingsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
1781+
///<summary>POST on /_nodes/{node_id}/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
1782+
///<param name="node_id">A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.</param>
1783+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1784+
TResponse NodesReloadSecureSettings<TResponse>(string node_id, ReloadSecureSettingsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
1785+
///<summary>POST on /_nodes/{node_id}/reload_secure_settings <para>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</para></summary>
1786+
///<param name="node_id">A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.</param>
1787+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1788+
Task<TResponse> NodesReloadSecureSettingsAsync<TResponse>(string node_id, ReloadSecureSettingsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
17751789
///<summary>GET on /_nodes/stats <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html</para></summary>
17761790
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
17771791
TResponse NodesStatsForAll<TResponse>(NodesStatsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Elasticsearch.Net;
6+
7+
namespace Nest
8+
{
9+
public partial interface IElasticClient
10+
{
11+
/// <summary>
12+
/// This API will decrypt and re-read the entire keystore, on every cluster node, but only the reloadable secure settings will
13+
/// be applied.
14+
/// <para>Changes to other settings will not go into effect until the next restart. Once the call returns, the reload has been
15+
/// completed, meaning that all internal datastructures dependent on these settings have been changed. Everything should look as if
16+
/// the settings had the new value from the start.</para>
17+
/// <para>
18+
/// When changing multiple reloadable secure settings, modify all of them, on each cluster node, and then issue a reload_secure_settings call,
19+
/// instead of reloading after each modification.</para>
20+
/// </summary>
21+
IReloadSecureSettingsResponse ReloadSecureSettings(Func<ReloadSecureSettingsDescriptor, IReloadSecureSettingsRequest> selector = null);
22+
23+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
24+
IReloadSecureSettingsResponse ReloadSecureSettings(IReloadSecureSettingsRequest request);
25+
26+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
27+
Task<IReloadSecureSettingsResponse> ReloadSecureSettingsAsync(
28+
Func<ReloadSecureSettingsDescriptor, IReloadSecureSettingsRequest> selector = null,
29+
CancellationToken cancellationToken = default
30+
);
31+
32+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
33+
Task<IReloadSecureSettingsResponse> ReloadSecureSettingsAsync(IReloadSecureSettingsRequest request,
34+
CancellationToken cancellationToken = default
35+
);
36+
}
37+
38+
public partial class ElasticClient
39+
{
40+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
41+
public IReloadSecureSettingsResponse ReloadSecureSettings(
42+
Func<ReloadSecureSettingsDescriptor, IReloadSecureSettingsRequest> selector = null
43+
) =>
44+
ReloadSecureSettings(selector.InvokeOrDefault(new ReloadSecureSettingsDescriptor()));
45+
46+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
47+
public IReloadSecureSettingsResponse ReloadSecureSettings(IReloadSecureSettingsRequest request) =>
48+
Dispatcher.Dispatch<IReloadSecureSettingsRequest, ReloadSecureSettingsRequestParameters, ReloadSecureSettingsResponse>(
49+
request,
50+
(p, d) => LowLevelDispatch.NodesReloadSecureSettingsDispatch<ReloadSecureSettingsResponse>(p)
51+
);
52+
53+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
54+
public Task<IReloadSecureSettingsResponse> ReloadSecureSettingsAsync(
55+
Func<ReloadSecureSettingsDescriptor, IReloadSecureSettingsRequest> selector = null,
56+
CancellationToken cancellationToken = default
57+
) =>
58+
ReloadSecureSettingsAsync(selector.InvokeOrDefault(new ReloadSecureSettingsDescriptor()), cancellationToken);
59+
60+
/// <inheritdoc cref="ReloadSecureSettings(System.Func{Nest.ReloadSecureSettingsDescriptor,Nest.IReloadSecureSettingsRequest})"/>
61+
public Task<IReloadSecureSettingsResponse> ReloadSecureSettingsAsync(IReloadSecureSettingsRequest request,
62+
CancellationToken cancellationToken = default
63+
) =>
64+
Dispatcher
65+
.DispatchAsync<IReloadSecureSettingsRequest, ReloadSecureSettingsRequestParameters, ReloadSecureSettingsResponse,
66+
IReloadSecureSettingsResponse>(
67+
request,
68+
cancellationToken,
69+
(p, d, c) => LowLevelDispatch.NodesReloadSecureSettingsDispatchAsync<ReloadSecureSettingsResponse>(p, c)
70+
);
71+
}
72+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Nest
2+
{
3+
[MapsApi("nodes.reload_secure_settings.json")]
4+
public partial interface IReloadSecureSettingsRequest { }
5+
6+
public partial class ReloadSecureSettingsRequest { }
7+
8+
public partial class ReloadSecureSettingsDescriptor { }
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Nest
5+
{
6+
public interface IReloadSecureSettingsResponse : INodesResponse
7+
{
8+
[JsonProperty("cluster_name")]
9+
string ClusterName { get; }
10+
11+
[JsonProperty("nodes")]
12+
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter<string, NodeStats>))]
13+
IReadOnlyDictionary<string, NodeStats> Nodes { get; }
14+
}
15+
16+
public class ReloadSecureSettingsResponse : NodesResponseBase, IReloadSecureSettingsResponse
17+
{
18+
public string ClusterName { get; internal set; }
19+
20+
public IReadOnlyDictionary<string, NodeStats> Nodes { get; internal set; } = EmptyReadOnly<string, NodeStats>.Dictionary;
21+
}
22+
}

src/Nest/_Generated/_Descriptors.generated.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,22 @@ public NodesInfoDescriptor() : base(){}
30043004
///<summary>Explicit operation timeout</summary>
30053005
public NodesInfoDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
30063006
}
3007+
///<summary>descriptor for NodesReloadSecureSettingsForAll <pre>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</pre></summary>
3008+
public partial class ReloadSecureSettingsDescriptor : RequestDescriptorBase<ReloadSecureSettingsDescriptor,ReloadSecureSettingsRequestParameters, IReloadSecureSettingsRequest>, IReloadSecureSettingsRequest
3009+
{
3010+
/// <summary>/_nodes/reload_secure_settings</summary>
3011+
public ReloadSecureSettingsDescriptor() : base(){}
3012+
// values part of the url path
3013+
NodeIds IReloadSecureSettingsRequest.NodeId => Self.RouteValues.Get<NodeIds>("node_id");
3014+
3015+
///<summary>A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.</summary>
3016+
public ReloadSecureSettingsDescriptor NodeId(NodeIds nodeId) => Assign(a=>a.RouteValues.Optional("node_id", nodeId));
3017+
3018+
// Request parameters
3019+
3020+
///<summary>Explicit operation timeout</summary>
3021+
public ReloadSecureSettingsDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
3022+
}
30073023
///<summary>descriptor for NodesStatsForAll <pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html</pre></summary>
30083024
public partial class NodesStatsDescriptor : RequestDescriptorBase<NodesStatsDescriptor,NodesStatsRequestParameters, INodesStatsRequest>, INodesStatsRequest
30093025
{

src/Nest/_Generated/_LowLevelDispatch.generated.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,28 @@ internal partial class LowLevelDispatch
22302230
throw InvalidDispatch("NodesInfo", p, new [] { GET }, "/_nodes", "/_nodes/{node_id}", "/_nodes/{metric}", "/_nodes/{node_id}/{metric}");
22312231
}
22322232

2233+
internal TResponse NodesReloadSecureSettingsDispatch<TResponse>(IRequest<ReloadSecureSettingsRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
2234+
{
2235+
switch(p.HttpMethod)
2236+
{
2237+
case POST:
2238+
if (AllSet(p.RouteValues.NodeId)) return _lowLevel.NodesReloadSecureSettings<TResponse>(p.RouteValues.NodeId,p.RequestParameters);
2239+
return _lowLevel.NodesReloadSecureSettingsForAll<TResponse>(p.RequestParameters);
2240+
}
2241+
throw InvalidDispatch("NodesReloadSecureSettings", p, new [] { POST }, "/_nodes/reload_secure_settings", "/_nodes/{node_id}/reload_secure_settings");
2242+
}
2243+
2244+
internal Task<TResponse> NodesReloadSecureSettingsDispatchAsync<TResponse>(IRequest<ReloadSecureSettingsRequestParameters> p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new()
2245+
{
2246+
switch(p.HttpMethod)
2247+
{
2248+
case POST:
2249+
if (AllSet(p.RouteValues.NodeId)) return _lowLevel.NodesReloadSecureSettingsAsync<TResponse>(p.RouteValues.NodeId,p.RequestParameters,ct);
2250+
return _lowLevel.NodesReloadSecureSettingsForAllAsync<TResponse>(p.RequestParameters,ct);
2251+
}
2252+
throw InvalidDispatch("NodesReloadSecureSettings", p, new [] { POST }, "/_nodes/reload_secure_settings", "/_nodes/{node_id}/reload_secure_settings");
2253+
}
2254+
22332255
internal TResponse NodesStatsDispatch<TResponse>(IRequest<NodesStatsRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
22342256
{
22352257
switch(p.HttpMethod)

src/Nest/_Generated/_Requests.generated.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4557,6 +4557,27 @@ public ReindexRethrottleRequest(TaskId task_id) : base(r=>r.Required("task_id",
45574557
public long? RequestsPerSecond { get => Q<long?>("requests_per_second"); set => Q("requests_per_second", value); }
45584558
}
45594559
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
4560+
public partial interface IReloadSecureSettingsRequest : IRequest<ReloadSecureSettingsRequestParameters>
4561+
{
4562+
NodeIds NodeId { get; }
4563+
}
4564+
///<summary>Request parameters for NodesReloadSecureSettingsForAll <pre>https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings</pre></summary>
4565+
public partial class ReloadSecureSettingsRequest : PlainRequestBase<ReloadSecureSettingsRequestParameters>, IReloadSecureSettingsRequest
4566+
{
4567+
protected IReloadSecureSettingsRequest Self => this;
4568+
///<summary>/_nodes/reload_secure_settings</summary>
4569+
public ReloadSecureSettingsRequest() : base(){}
4570+
///<summary>/_nodes/{node_id}/reload_secure_settings</summary>
4571+
///<param name="node_id">Optional, accepts null</param>
4572+
public ReloadSecureSettingsRequest(NodeIds node_id) : base(r=>r.Optional("node_id", node_id)){}
4573+
// values part of the url path
4574+
NodeIds IReloadSecureSettingsRequest.NodeId => Self.RouteValues.Get<NodeIds>("node_id");
4575+
4576+
// Request parameters
4577+
///<summary>Explicit operation timeout</summary>
4578+
public Time Timeout { get => Q<Time>("timeout"); set => Q("timeout", value); }
4579+
}
4580+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
45604581
public partial interface IRemoteInfoRequest : IRequest<RemoteInfoRequestParameters>
45614582
{
45624583
}

0 commit comments

Comments
 (0)