diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs index c7c74dd5e91..df9000863ed 100644 --- a/src/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs @@ -66,7 +66,6 @@ public static class CodeConfiguration "cluster.delete_component_template.json", "cluster.get_component_template.json", "cluster.put_component_template.json", - "indices.reload_search_analyzers.json", "ml.estimate_model_memory.json", "ml.set_upgrade_mode.json", "security.get_builtin_privileges.json", diff --git a/src/Nest/Descriptors.Indices.cs b/src/Nest/Descriptors.Indices.cs index 2a079309ad5..2e4ee074d83 100644 --- a/src/Nest/Descriptors.Indices.cs +++ b/src/Nest/Descriptors.Indices.cs @@ -1118,6 +1118,40 @@ public RefreshDescriptor Index() public RefreshDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable); } + ///Descriptor for ReloadSearchAnalyzers https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + public partial class ReloadSearchAnalyzersDescriptor : RequestDescriptorBase, IReloadSearchAnalyzersRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesReloadSearchAnalyzers; + ////{index}/_reload_search_analyzers + ///this parameter is required + public ReloadSearchAnalyzersDescriptor(Indices index): base(r => r.Required("index", index)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected ReloadSearchAnalyzersDescriptor(): base() + { + } + + // values part of the url path + Indices IReloadSearchAnalyzersRequest.Index => Self.RouteValues.Get("index"); + ///A comma-separated list of index names to reload analyzers for + public ReloadSearchAnalyzersDescriptor Index(Indices index) => Assign(index, (a, v) => a.RouteValues.Required("index", v)); + ///a shortcut into calling Index(typeof(TOther)) + public ReloadSearchAnalyzersDescriptor Index() + where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (Indices)v)); + ///A shortcut into calling Index(Indices.All) + public ReloadSearchAnalyzersDescriptor AllIndices() => Index(Indices.All); + // Request parameters + ///Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + public ReloadSearchAnalyzersDescriptor AllowNoIndices(bool? allownoindices = true) => Qs("allow_no_indices", allownoindices); + ///Whether to expand wildcard expression to concrete indices that are open, closed or both. + public ReloadSearchAnalyzersDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => Qs("expand_wildcards", expandwildcards); + ///Whether specified concrete indices should be ignored when unavailable (missing or closed) + public ReloadSearchAnalyzersDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable); + } + ///Descriptor for Rollover https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html public partial class RolloverIndexDescriptor : RequestDescriptorBase, IRolloverIndexRequest { diff --git a/src/Nest/ElasticClient.Indices.cs b/src/Nest/ElasticClient.Indices.cs index 413edbc66d9..291f7d3215f 100644 --- a/src/Nest/ElasticClient.Indices.cs +++ b/src/Nest/ElasticClient.Indices.cs @@ -739,6 +739,30 @@ public Task PutMappingAsync(Func public Task RefreshAsync(IRefreshRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); /// + /// POST request to the indices.reload_search_analyzers API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + /// + public ReloadSearchAnalyzersResponse ReloadSearchAnalyzers(Indices index, Func selector = null) => ReloadSearchAnalyzers(selector.InvokeOrDefault(new ReloadSearchAnalyzersDescriptor(index: index))); + /// + /// POST request to the indices.reload_search_analyzers API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + /// + public Task ReloadSearchAnalyzersAsync(Indices index, Func selector = null, CancellationToken ct = default) => ReloadSearchAnalyzersAsync(selector.InvokeOrDefault(new ReloadSearchAnalyzersDescriptor(index: index)), ct); + /// + /// POST request to the indices.reload_search_analyzers API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + /// + public ReloadSearchAnalyzersResponse ReloadSearchAnalyzers(IReloadSearchAnalyzersRequest request) => DoRequest(request, request.RequestParameters); + /// + /// POST request to the indices.reload_search_analyzers API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + /// + public Task ReloadSearchAnalyzersAsync(IReloadSearchAnalyzersRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); + /// /// POST request to the indices.rollover API, read more about this API online: /// /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html diff --git a/src/Nest/Indices/ReloadSearchAnalyzers/ReloadDetails.cs b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadDetails.cs new file mode 100644 index 00000000000..2c1eee498fd --- /dev/null +++ b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadDetails.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Runtime.Serialization; +using Elasticsearch.Net; + +namespace Nest +{ + public class ReloadDetails + { + [DataMember(Name ="index")] + public string Index { get; internal set; } + + [DataMember(Name ="reloaded_analyzers")] + public IReadOnlyCollection ReloadedAnalyzers { get; internal set; } = EmptyReadOnly.Collection; + + [DataMember(Name ="reloaded_node_ids")] + public IReadOnlyCollection ReloadedNodeIds { get; internal set; } = EmptyReadOnly.Collection; + } +} diff --git a/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersRequest.cs b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersRequest.cs new file mode 100644 index 00000000000..45da820f4e0 --- /dev/null +++ b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("indices.reload_search_analyzers.json")] + public partial interface IReloadSearchAnalyzersRequest { } + + public partial class ReloadSearchAnalyzersRequest { } + + public partial class ReloadSearchAnalyzersDescriptor { } +} diff --git a/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersResponse.cs b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersResponse.cs new file mode 100644 index 00000000000..ca9e90b00fd --- /dev/null +++ b/src/Nest/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersResponse.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Runtime.Serialization; +using Elasticsearch.Net; + +namespace Nest +{ + public class ReloadSearchAnalyzersResponse : ResponseBase + { + [DataMember(Name ="_shards")] + public ShardStatistics Shards { get; internal set; } + + [DataMember(Name ="reload_details")] + public IReadOnlyCollection ReloadDetails { get; internal set; } = EmptyReadOnly.Collection; + } +} diff --git a/src/Nest/Requests.Indices.cs b/src/Nest/Requests.Indices.cs index 1b3d30db173..06ba201d4ec 100644 --- a/src/Nest/Requests.Indices.cs +++ b/src/Nest/Requests.Indices.cs @@ -2055,6 +2055,62 @@ public bool? IgnoreUnavailable } } + [InterfaceDataContract] + public partial interface IReloadSearchAnalyzersRequest : IRequest + { + [IgnoreDataMember] + Indices Index + { + get; + } + } + + ///Request for ReloadSearchAnalyzers https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + public partial class ReloadSearchAnalyzersRequest : PlainRequestBase, IReloadSearchAnalyzersRequest + { + protected IReloadSearchAnalyzersRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesReloadSearchAnalyzers; + ////{index}/_reload_search_analyzers + ///this parameter is required + public ReloadSearchAnalyzersRequest(Indices index): base(r => r.Required("index", index)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected ReloadSearchAnalyzersRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Indices IReloadSearchAnalyzersRequest.Index => Self.RouteValues.Get("index"); + // Request parameters + /// + /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have + /// been specified) + /// + public bool? AllowNoIndices + { + get => Q("allow_no_indices"); + set => Q("allow_no_indices", value); + } + + ///Whether to expand wildcard expression to concrete indices that are open, closed or both. + public ExpandWildcards? ExpandWildcards + { + get => Q("expand_wildcards"); + set => Q("expand_wildcards", value); + } + + ///Whether specified concrete indices should be ignored when unavailable (missing or closed) + public bool? IgnoreUnavailable + { + get => Q("ignore_unavailable"); + set => Q("ignore_unavailable", value); + } + } + [InterfaceDataContract] public partial interface IRolloverIndexRequest : IRequest { diff --git a/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersApiTests.cs b/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersApiTests.cs new file mode 100644 index 00000000000..35ced8bad4c --- /dev/null +++ b/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersApiTests.cs @@ -0,0 +1,38 @@ +using System; +using Elastic.Xunit.XunitPlumbing; +using Elasticsearch.Net; +using Nest; +using Tests.Core.Extensions; +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Framework.EndpointTests; +using Tests.Framework.EndpointTests.TestState; + +namespace Tests.Indices.ReloadSearchAnalyzers +{ + [SkipVersion("<7.7.0", "Introduced in 7.7.0")] + public class ReloadSearchAnalyzersApiTests + : ApiIntegrationTestBase + { + public ReloadSearchAnalyzersApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + + protected override ReloadSearchAnalyzersDescriptor NewDescriptor() => new ReloadSearchAnalyzersDescriptor(CallIsolatedValue); + + protected override Func Fluent => d => d.Index(CallIsolatedValue); + protected override HttpMethod HttpMethod => HttpMethod.POST; + + protected override ReloadSearchAnalyzersRequest Initializer => new ReloadSearchAnalyzersRequest(CallIsolatedValue); + protected override string UrlPath => $"/{CallIsolatedValue}/_reload_search_analyzers"; + + protected override LazyResponses ClientUsage() => Calls( + (client, f) => client.Indices.ReloadSearchAnalyzers(CallIsolatedValue, f), + (client, f) => client.Indices.ReloadSearchAnalyzersAsync(CallIsolatedValue, f), + (client, r) => client.Indices.ReloadSearchAnalyzers(r), + (client, r) => client.Indices.ReloadSearchAnalyzersAsync(r) + ); + + protected override void ExpectResponse(ReloadSearchAnalyzersResponse response) => response.ShouldBeValid(); + } +} diff --git a/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersUrlTests.cs b/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersUrlTests.cs new file mode 100644 index 00000000000..4346b337215 --- /dev/null +++ b/tests/Tests/Indices/ReloadSearchAnalyzers/ReloadSearchAnalyzersUrlTests.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; +using static Nest.Indices; + +namespace Tests.Indices.ReloadSearchAnalyzers +{ + public class ReloadSearchAnalyzersUrlTests + { + [U] public async Task Urls() + { + await POST($"/_all/_reload_search_analyzers") + .Fluent(c => c.Indices.ReloadSearchAnalyzers(All)) + .Request(c => c.Indices.ReloadSearchAnalyzers(new ReloadSearchAnalyzersRequest(All))) + .FluentAsync(c => c.Indices.ReloadSearchAnalyzersAsync(All)) + .RequestAsync(c => c.Indices.ReloadSearchAnalyzersAsync(new ReloadSearchAnalyzersRequest(All))) + ; + + var index = "index1,index2"; + await POST($"/index1%2Cindex2/_reload_search_analyzers") + .Fluent(c => c.Indices.ReloadSearchAnalyzers(index)) + .Request(c => c.Indices.ReloadSearchAnalyzers(new ReloadSearchAnalyzersRequest(index))) + .FluentAsync(c => c.Indices.ReloadSearchAnalyzersAsync(index)) + .RequestAsync(c => c.Indices.ReloadSearchAnalyzersAsync(new ReloadSearchAnalyzersRequest(index))) + ; + } + } +}