diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs
index 80baf26d45d..b58766cf819 100644
--- a/src/ApiGenerator/Configuration/CodeConfiguration.cs
+++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs
@@ -35,7 +35,6 @@ public static class CodeConfiguration
public static string[] IgnoredApisHighLevel { get; } =
{
- "indices.add_block.json", // TODO: implement
"indices.resolve_index.json", // TODO: implement
"security.clear_cached_privileges.json", // TODO: implement
diff --git a/src/ApiGenerator/Domain/Specification/UrlPart.cs b/src/ApiGenerator/Domain/Specification/UrlPart.cs
index d5e496ae833..d5017d20099 100644
--- a/src/ApiGenerator/Domain/Specification/UrlPart.cs
+++ b/src/ApiGenerator/Domain/Specification/UrlPart.cs
@@ -104,6 +104,9 @@ public string HighLevelTypeName
case "type":
return Type == "string" ? "Name" : "Names";
+ case "block":
+ return "IndexBlock";
+
case "index_uuid":
return "IndexUuid";
diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs
index 70de23c43b7..3ad4606cf19 100644
--- a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs
+++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs
@@ -25,7 +25,7 @@
namespace Elasticsearch.Net.Specification.IndicesApi
{
///Request options for AddBlock https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
- public class AddBlockRequestParameters : RequestParameters
+ public class AddIndexBlockRequestParameters : RequestParameters
{
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
public override bool SupportsBody => false;
diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs
index 442240316bf..608771cef6d 100644
--- a/src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs
+++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs
@@ -47,14 +47,14 @@ internal LowLevelIndicesNamespace(ElasticLowLevelClient client): base(client)
///A comma separated list of indices to add a block to
///The block to add (one of read, write, read_only or metadata)
///Request specific configuration such as querystring parameters & request specific connection settings.
- public TResponse AddBlock(string index, string block, AddBlockRequestParameters requestParameters = null)
+ public TResponse AddBlock(string index, string block, AddIndexBlockRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => DoRequest(PUT, Url($"{index:index}/_block/{block:block}"), null, RequestParams(requestParameters));
///PUT on /{index}/_block/{block} https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
///A comma separated list of indices to add a block to
///The block to add (one of read, write, read_only or metadata)
///Request specific configuration such as querystring parameters & request specific connection settings.
[MapsApi("indices.add_block", "index, block")]
- public Task AddBlockAsync(string index, string block, AddBlockRequestParameters requestParameters = null, CancellationToken ctx = default)
+ public Task AddBlockAsync(string index, string block, AddIndexBlockRequestParameters requestParameters = null, CancellationToken ctx = default)
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(PUT, Url($"{index:index}/_block/{block:block}"), ctx, null, RequestParams(requestParameters));
///POST on /_analyze https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html
///Define analyzer/tokenizer parameters and the text on which the analysis should be performed
diff --git a/src/Nest/Descriptors.Indices.cs b/src/Nest/Descriptors.Indices.cs
index 1bbc4c79f30..c64851df3d0 100644
--- a/src/Nest/Descriptors.Indices.cs
+++ b/src/Nest/Descriptors.Indices.cs
@@ -30,6 +30,46 @@
// ReSharper disable RedundantNameQualifier
namespace Nest
{
+ ///Descriptor for AddBlock https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ public partial class AddIndexBlockDescriptor : RequestDescriptorBase, IAddIndexBlockRequest
+ {
+ internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesAddBlock;
+ ////{index}/_block/{block}
+ ///this parameter is required
+ ///this parameter is required
+ public AddIndexBlockDescriptor(Indices index, IndexBlock block): base(r => r.Required("index", index).Required("block", block))
+ {
+ }
+
+ ///Used for serialization purposes, making sure we have a parameterless constructor
+ [SerializationConstructor]
+ protected AddIndexBlockDescriptor(): base()
+ {
+ }
+
+ // values part of the url path
+ Indices IAddIndexBlockRequest.Index => Self.RouteValues.Get("index");
+ IndexBlock IAddIndexBlockRequest.Block => Self.RouteValues.Get("block");
+ ///A comma separated list of indices to add a block to
+ public AddIndexBlockDescriptor Index(Indices index) => Assign(index, (a, v) => a.RouteValues.Required("index", v));
+ ///a shortcut into calling Index(typeof(TOther))
+ public AddIndexBlockDescriptor Index()
+ where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (Indices)v));
+ ///A shortcut into calling Index(Indices.All)
+ public AddIndexBlockDescriptor 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 AddIndexBlockDescriptor AllowNoIndices(bool? allownoindices = true) => Qs("allow_no_indices", allownoindices);
+ ///Whether to expand wildcard expression to concrete indices that are open, closed or both.
+ public AddIndexBlockDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => Qs("expand_wildcards", expandwildcards);
+ ///Whether specified concrete indices should be ignored when unavailable (missing or closed)
+ public AddIndexBlockDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable);
+ ///Specify timeout for connection to master
+ public AddIndexBlockDescriptor MasterTimeout(Time mastertimeout) => Qs("master_timeout", mastertimeout);
+ ///Explicit operation timeout
+ public AddIndexBlockDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
+ }
+
///Descriptor for Analyze https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html
public partial class AnalyzeDescriptor : RequestDescriptorBase, IAnalyzeRequest
{
diff --git a/src/Nest/ElasticClient.Indices.cs b/src/Nest/ElasticClient.Indices.cs
index 131772c4324..7ad282ae207 100644
--- a/src/Nest/ElasticClient.Indices.cs
+++ b/src/Nest/ElasticClient.Indices.cs
@@ -36,6 +36,30 @@ internal IndicesNamespace(ElasticClient client): base(client)
{
}
+ ///
+ /// PUT request to the indices.add_block API, read more about this API online:
+ ///
+ /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ ///
+ public AddIndexBlockResponse AddBlock(Indices index, IndexBlock block, Func selector = null) => AddBlock(selector.InvokeOrDefault(new AddIndexBlockDescriptor(index: index, block: block)));
+ ///
+ /// PUT request to the indices.add_block API, read more about this API online:
+ ///
+ /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ ///
+ public Task AddBlockAsync(Indices index, IndexBlock block, Func selector = null, CancellationToken ct = default) => AddBlockAsync(selector.InvokeOrDefault(new AddIndexBlockDescriptor(index: index, block: block)), ct);
+ ///
+ /// PUT request to the indices.add_block API, read more about this API online:
+ ///
+ /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ ///
+ public AddIndexBlockResponse AddBlock(IAddIndexBlockRequest request) => DoRequest(request, request.RequestParameters);
+ ///
+ /// PUT request to the indices.add_block API, read more about this API online:
+ ///
+ /// https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ ///
+ public Task AddBlockAsync(IAddIndexBlockRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct);
///
/// POST request to the indices.analyze API, read more about this API online:
///
diff --git a/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockRequest.cs b/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockRequest.cs
new file mode 100644
index 00000000000..5d8a8ebde01
--- /dev/null
+++ b/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockRequest.cs
@@ -0,0 +1,25 @@
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information
+
+namespace Nest
+{
+ ///
+ /// A request to the indices add block API
+ ///
+ [MapsApi("indices.add_block.json")]
+ [ReadAs(typeof(AddIndexBlockRequest))]
+ public partial interface IAddIndexBlockRequest
+ {
+ }
+
+ ///
+ public partial class AddIndexBlockRequest
+ {
+ }
+
+ ///
+ public partial class AddIndexBlockDescriptor
+ {
+ }
+}
diff --git a/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockResponse.cs b/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockResponse.cs
new file mode 100644
index 00000000000..83eb4a55699
--- /dev/null
+++ b/src/Nest/Indices/IndexManagement/AddBlock/AddIndexBlockResponse.cs
@@ -0,0 +1,28 @@
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using Elasticsearch.Net;
+
+namespace Nest
+{
+ public class AddIndexBlockResponse : AcknowledgedResponseBase
+ {
+ [DataMember(Name = "shards_acknowledged")]
+ public bool ShardsAcknowledged { get; internal set; }
+
+ [DataMember(Name = "indices")]
+ public IReadOnlyCollection Indices { get; internal set; } = EmptyReadOnly.Collection;
+ }
+
+ public class BlockedIndex
+ {
+ [DataMember(Name = "name")]
+ public string Name { get; internal set; }
+
+ [DataMember(Name = "blocked")]
+ public bool Blocked { get; internal set; }
+ }
+}
diff --git a/src/Nest/Indices/IndexManagement/AddBlock/IndexBlock.cs b/src/Nest/Indices/IndexManagement/AddBlock/IndexBlock.cs
new file mode 100644
index 00000000000..970b2316a26
--- /dev/null
+++ b/src/Nest/Indices/IndexManagement/AddBlock/IndexBlock.cs
@@ -0,0 +1,44 @@
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information
+
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information
+
+using Elasticsearch.Net;
+
+namespace Nest
+{
+ ///
+ /// Block type for an index.
+ ///
+ public class IndexBlock : IUrlParameter
+ {
+ private IndexBlock(string value) => Value = value;
+
+ public string Value { get; }
+
+ public string GetString(IConnectionConfigurationValues settings) => Value;
+
+ ///
+ /// Disable metadata changes, such as closing the index.
+ ///
+ public static IndexBlock Metadata { get; } = new IndexBlock("metadata");
+
+ ///
+ /// Disable read operations.
+ ///
+ public static IndexBlock Read { get; } = new IndexBlock("read");
+
+ ///
+ /// Disable write operations and metadata changes.
+ ///
+ public static IndexBlock ReadOnly { get; } = new IndexBlock("read_only");
+
+ ///
+ /// Disable write operations. However, metadata changes are still allowed.
+ ///
+ public static IndexBlock Write { get; } = new IndexBlock("write");
+ }
+}
diff --git a/src/Nest/Requests.Indices.cs b/src/Nest/Requests.Indices.cs
index c450f615b9c..40c587ad275 100644
--- a/src/Nest/Requests.Indices.cs
+++ b/src/Nest/Requests.Indices.cs
@@ -31,6 +31,85 @@
// ReSharper disable RedundantNameQualifier
namespace Nest
{
+ [InterfaceDataContract]
+ public partial interface IAddIndexBlockRequest : IRequest
+ {
+ [IgnoreDataMember]
+ Indices Index
+ {
+ get;
+ }
+
+ [IgnoreDataMember]
+ IndexBlock Block
+ {
+ get;
+ }
+ }
+
+ ///Request for AddBlock https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
+ public partial class AddIndexBlockRequest : PlainRequestBase, IAddIndexBlockRequest
+ {
+ protected IAddIndexBlockRequest Self => this;
+ internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesAddBlock;
+ ////{index}/_block/{block}
+ ///this parameter is required
+ ///this parameter is required
+ public AddIndexBlockRequest(Indices index, IndexBlock block): base(r => r.Required("index", index).Required("block", block))
+ {
+ }
+
+ ///Used for serialization purposes, making sure we have a parameterless constructor
+ [SerializationConstructor]
+ protected AddIndexBlockRequest(): base()
+ {
+ }
+
+ // values part of the url path
+ [IgnoreDataMember]
+ Indices IAddIndexBlockRequest.Index => Self.RouteValues.Get("index");
+ [IgnoreDataMember]
+ IndexBlock IAddIndexBlockRequest.Block => Self.RouteValues.Get("block");
+ // 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);
+ }
+
+ ///Specify timeout for connection to master
+ public Time MasterTimeout
+ {
+ get => Q