Skip to content

Commit 7cd8613

Browse files
codebrainrusscam
authored andcommitted
Implement Freeze and Unfreeze API (#3940)
This commit implements the index freeze and unfreeze APIs
1 parent 2490f71 commit 7cd8613

File tree

15 files changed

+559
-2
lines changed

15 files changed

+559
-2
lines changed

src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public static class CodeConfiguration
2222
"ml.set_upgrade_mode.json",
2323
"ml.find_file_structure.json",
2424
"monitoring.bulk.json",
25-
"indices.freeze.json",
26-
"indices.unfreeze.json",
2725

2826
"ccr.follow_info.json",
2927
"ccr.forget_follower.json"

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,56 @@ public bool? OnlyExpungeDeletes
527527
}
528528
}
529529

530+
///<summary>Request options for Freeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
531+
public class FreezeIndexRequestParameters : RequestParameters<FreezeIndexRequestParameters>
532+
{
533+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
534+
///<summary>
535+
/// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have
536+
/// been specified)
537+
///</summary>
538+
public bool? AllowNoIndices
539+
{
540+
get => Q<bool? >("allow_no_indices");
541+
set => Q("allow_no_indices", value);
542+
}
543+
544+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
545+
public ExpandWildcards? ExpandWildcards
546+
{
547+
get => Q<ExpandWildcards? >("expand_wildcards");
548+
set => Q("expand_wildcards", value);
549+
}
550+
551+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
552+
public bool? IgnoreUnavailable
553+
{
554+
get => Q<bool? >("ignore_unavailable");
555+
set => Q("ignore_unavailable", value);
556+
}
557+
558+
///<summary>Specify timeout for connection to master</summary>
559+
public TimeSpan MasterTimeout
560+
{
561+
get => Q<TimeSpan>("master_timeout");
562+
set => Q("master_timeout", value);
563+
}
564+
565+
///<summary>Explicit operation timeout</summary>
566+
public TimeSpan Timeout
567+
{
568+
get => Q<TimeSpan>("timeout");
569+
set => Q("timeout", value);
570+
}
571+
572+
///<summary>Sets the number of active shards to wait for before the operation returns.</summary>
573+
public string WaitForActiveShards
574+
{
575+
get => Q<string>("wait_for_active_shards");
576+
set => Q("wait_for_active_shards", value);
577+
}
578+
}
579+
530580
///<summary>Request options for Get <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html</para></summary>
531581
public class GetIndexRequestParameters : RequestParameters<GetIndexRequestParameters>
532582
{
@@ -1289,6 +1339,56 @@ public Level? Level
12891339
}
12901340
}
12911341

1342+
///<summary>Request options for Unfreeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
1343+
public class UnfreezeIndexRequestParameters : RequestParameters<UnfreezeIndexRequestParameters>
1344+
{
1345+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
1346+
///<summary>
1347+
/// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have
1348+
/// been specified)
1349+
///</summary>
1350+
public bool? AllowNoIndices
1351+
{
1352+
get => Q<bool? >("allow_no_indices");
1353+
set => Q("allow_no_indices", value);
1354+
}
1355+
1356+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
1357+
public ExpandWildcards? ExpandWildcards
1358+
{
1359+
get => Q<ExpandWildcards? >("expand_wildcards");
1360+
set => Q("expand_wildcards", value);
1361+
}
1362+
1363+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
1364+
public bool? IgnoreUnavailable
1365+
{
1366+
get => Q<bool? >("ignore_unavailable");
1367+
set => Q("ignore_unavailable", value);
1368+
}
1369+
1370+
///<summary>Specify timeout for connection to master</summary>
1371+
public TimeSpan MasterTimeout
1372+
{
1373+
get => Q<TimeSpan>("master_timeout");
1374+
set => Q("master_timeout", value);
1375+
}
1376+
1377+
///<summary>Explicit operation timeout</summary>
1378+
public TimeSpan Timeout
1379+
{
1380+
get => Q<TimeSpan>("timeout");
1381+
set => Q("timeout", value);
1382+
}
1383+
1384+
///<summary>Sets the number of active shards to wait for before the operation returns.</summary>
1385+
public string WaitForActiveShards
1386+
{
1387+
get => Q<string>("wait_for_active_shards");
1388+
set => Q("wait_for_active_shards", value);
1389+
}
1390+
}
1391+
12921392
///<summary>Request options for BulkAlias <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html</para></summary>
12931393
public class BulkAliasRequestParameters : RequestParameters<BulkAliasRequestParameters>
12941394
{

src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ public TResponse ForceMerge<TResponse>(string index, ForceMergeRequestParameters
245245
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
246246
public Task<TResponse> ForceMergeAsync<TResponse>(string index, ForceMergeRequestParameters requestParameters = null, CancellationToken ctx = default)
247247
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_forcemerge"), ctx, null, RequestParams(requestParameters));
248+
///<summary>POST on /{index}/_freeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
249+
///<param name = "index">The name of the index to freeze</param>
250+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
251+
public TResponse Freeze<TResponse>(string index, FreezeIndexRequestParameters requestParameters = null)
252+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, Url($"{index:index}/_freeze"), null, RequestParams(requestParameters));
253+
///<summary>POST on /{index}/_freeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
254+
///<param name = "index">The name of the index to freeze</param>
255+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
256+
public Task<TResponse> FreezeAsync<TResponse>(string index, FreezeIndexRequestParameters requestParameters = null, CancellationToken ctx = default)
257+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_freeze"), ctx, null, RequestParams(requestParameters));
248258
///<summary>GET on /{index} <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html</para></summary>
249259
///<param name = "index">A comma-separated list of index names</param>
250260
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
@@ -715,6 +725,16 @@ public TResponse Stats<TResponse>(string index, string metric, IndicesStatsReque
715725
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
716726
public Task<TResponse> StatsAsync<TResponse>(string index, string metric, IndicesStatsRequestParameters requestParameters = null, CancellationToken ctx = default)
717727
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"{index:index}/_stats/{metric:metric}"), ctx, null, RequestParams(requestParameters));
728+
///<summary>POST on /{index}/_unfreeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
729+
///<param name = "index">The name of the index to unfreeze</param>
730+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
731+
public TResponse Unfreeze<TResponse>(string index, UnfreezeIndexRequestParameters requestParameters = null)
732+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, Url($"{index:index}/_unfreeze"), null, RequestParams(requestParameters));
733+
///<summary>POST on /{index}/_unfreeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
734+
///<param name = "index">The name of the index to unfreeze</param>
735+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
736+
public Task<TResponse> UnfreezeAsync<TResponse>(string index, UnfreezeIndexRequestParameters requestParameters = null, CancellationToken ctx = default)
737+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_unfreeze"), ctx, null, RequestParams(requestParameters));
718738
///<summary>POST on /_aliases <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html</para></summary>
719739
///<param name = "body">The definition of `actions` to perform</param>
720740
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>

src/Nest/Descriptors.Indices.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,44 @@ public ForceMergeDescriptor Index<TOther>()
526526
public ForceMergeDescriptor OnlyExpungeDeletes(bool? onlyexpungedeletes = true) => Qs("only_expunge_deletes", onlyexpungedeletes);
527527
}
528528

529+
///<summary>descriptor for Freeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
530+
public partial class FreezeIndexDescriptor : RequestDescriptorBase<FreezeIndexDescriptor, FreezeIndexRequestParameters, IFreezeIndexRequest>, IFreezeIndexRequest
531+
{
532+
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesFreeze;
533+
///<summary>/{index}/_freeze</summary>
534+
///<param name = "index">this parameter is required</param>
535+
public FreezeIndexDescriptor(IndexName index): base(r => r.Required("index", index))
536+
{
537+
}
538+
539+
///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
540+
[SerializationConstructor]
541+
protected FreezeIndexDescriptor(): base()
542+
{
543+
}
544+
545+
// values part of the url path
546+
IndexName IFreezeIndexRequest.Index => Self.RouteValues.Get<IndexName>("index");
547+
///<summary>The name of the index to freeze</summary>
548+
public FreezeIndexDescriptor Index(IndexName index) => Assign(index, (a, v) => a.RouteValues.Required("index", v));
549+
///<summary>a shortcut into calling Index(typeof(TOther))</summary>
550+
public FreezeIndexDescriptor Index<TOther>()
551+
where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (IndexName)v));
552+
// Request parameters
553+
///<summary>Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)</summary>
554+
public FreezeIndexDescriptor AllowNoIndices(bool? allownoindices = true) => Qs("allow_no_indices", allownoindices);
555+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
556+
public FreezeIndexDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => Qs("expand_wildcards", expandwildcards);
557+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
558+
public FreezeIndexDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable);
559+
///<summary>Specify timeout for connection to master</summary>
560+
public FreezeIndexDescriptor MasterTimeout(Time mastertimeout) => Qs("master_timeout", mastertimeout);
561+
///<summary>Explicit operation timeout</summary>
562+
public FreezeIndexDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
563+
///<summary>Sets the number of active shards to wait for before the operation returns.</summary>
564+
public FreezeIndexDescriptor WaitForActiveShards(string waitforactiveshards) => Qs("wait_for_active_shards", waitforactiveshards);
565+
}
566+
529567
///<summary>descriptor for Get <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html</para></summary>
530568
public partial class GetIndexDescriptor : RequestDescriptorBase<GetIndexDescriptor, GetIndexRequestParameters, IGetIndexRequest>, IGetIndexRequest
531569
{
@@ -1287,6 +1325,44 @@ public IndicesStatsDescriptor Fields<T>(params Expression<Func<T, object>>[] fie
12871325
public IndicesStatsDescriptor Level(Level? level) => Qs("level", level);
12881326
}
12891327

1328+
///<summary>descriptor for Unfreeze <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html</para></summary>
1329+
public partial class UnfreezeIndexDescriptor : RequestDescriptorBase<UnfreezeIndexDescriptor, UnfreezeIndexRequestParameters, IUnfreezeIndexRequest>, IUnfreezeIndexRequest
1330+
{
1331+
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesUnfreeze;
1332+
///<summary>/{index}/_unfreeze</summary>
1333+
///<param name = "index">this parameter is required</param>
1334+
public UnfreezeIndexDescriptor(IndexName index): base(r => r.Required("index", index))
1335+
{
1336+
}
1337+
1338+
///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
1339+
[SerializationConstructor]
1340+
protected UnfreezeIndexDescriptor(): base()
1341+
{
1342+
}
1343+
1344+
// values part of the url path
1345+
IndexName IUnfreezeIndexRequest.Index => Self.RouteValues.Get<IndexName>("index");
1346+
///<summary>The name of the index to unfreeze</summary>
1347+
public UnfreezeIndexDescriptor Index(IndexName index) => Assign(index, (a, v) => a.RouteValues.Required("index", v));
1348+
///<summary>a shortcut into calling Index(typeof(TOther))</summary>
1349+
public UnfreezeIndexDescriptor Index<TOther>()
1350+
where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (IndexName)v));
1351+
// Request parameters
1352+
///<summary>Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)</summary>
1353+
public UnfreezeIndexDescriptor AllowNoIndices(bool? allownoindices = true) => Qs("allow_no_indices", allownoindices);
1354+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
1355+
public UnfreezeIndexDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => Qs("expand_wildcards", expandwildcards);
1356+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
1357+
public UnfreezeIndexDescriptor IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable);
1358+
///<summary>Specify timeout for connection to master</summary>
1359+
public UnfreezeIndexDescriptor MasterTimeout(Time mastertimeout) => Qs("master_timeout", mastertimeout);
1360+
///<summary>Explicit operation timeout</summary>
1361+
public UnfreezeIndexDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
1362+
///<summary>Sets the number of active shards to wait for before the operation returns.</summary>
1363+
public UnfreezeIndexDescriptor WaitForActiveShards(string waitforactiveshards) => Qs("wait_for_active_shards", waitforactiveshards);
1364+
}
1365+
12901366
///<summary>descriptor for BulkAlias <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html</para></summary>
12911367
public partial class BulkAliasDescriptor : RequestDescriptorBase<BulkAliasDescriptor, BulkAliasRequestParameters, IBulkAliasRequest>, IBulkAliasRequest
12921368
{

0 commit comments

Comments
 (0)