diff --git a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs index 6fb1721bb92..2d396bef67d 100644 --- a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs +++ b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs @@ -3708,12 +3708,12 @@ public PutWarmerRequestParameters ExpandWildcards(ExpandWildcards expand_wildcar ///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-recovery.html /// /// - public class IndicesRecoveryRequestParameters : FluentRequestParameters + public class RecoveryStatusRequestParameters : FluentRequestParameters { internal bool _detailed { get; set; } ///Whether to display detailed information about shard recovery - public IndicesRecoveryRequestParameters Detailed(bool detailed) + public RecoveryStatusRequestParameters Detailed(bool detailed) { this._detailed = detailed; this.AddQueryString("detailed", this._detailed); @@ -3723,7 +3723,7 @@ public IndicesRecoveryRequestParameters Detailed(bool detailed) internal bool _active_only { get; set; } ///Display only those recoveries that are currently on-going - public IndicesRecoveryRequestParameters ActiveOnly(bool active_only) + public RecoveryStatusRequestParameters ActiveOnly(bool active_only) { this._active_only = active_only; this.AddQueryString("active_only", this._active_only); @@ -3733,7 +3733,7 @@ public IndicesRecoveryRequestParameters ActiveOnly(bool active_only) internal bool _human { get; set; } ///Whether to return time and byte values in human-readable format. - public IndicesRecoveryRequestParameters Human(bool human) + public RecoveryStatusRequestParameters Human(bool human) { this._human = human; this.AddQueryString("human", this._human); diff --git a/src/Elasticsearch.Net/Elasticsearch.Net.csproj b/src/Elasticsearch.Net/Elasticsearch.Net.csproj index 16d59fe1afa..4bc93eaeab2 100644 --- a/src/Elasticsearch.Net/Elasticsearch.Net.csproj +++ b/src/Elasticsearch.Net/Elasticsearch.Net.csproj @@ -67,6 +67,7 @@ + diff --git a/src/Elasticsearch.Net/ElasticsearchClient.Generated.cs b/src/Elasticsearch.Net/ElasticsearchClient.Generated.cs index 27ccedbf40f..4dd29ac211c 100644 --- a/src/Elasticsearch.Net/ElasticsearchClient.Generated.cs +++ b/src/Elasticsearch.Net/ElasticsearchClient.Generated.cs @@ -20319,14 +20319,14 @@ public Task> IndicesPutWarmerPostAsync( /// - If T is of type byte[] deserialization will be shortcircuited /// - If T is of type VoidResponse the response stream will be ignored completely /// - public ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null) + public ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null) { var url = "_recovery"; IRequestParameters requestParams = null; if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20351,14 +20351,14 @@ public ElasticsearchResponse IndicesRecoveryForAll(Func - If T is of type byte[] deserialization will be shortcircuited /// - If T is of type VoidResponse the response stream will be ignored completely /// - public Task> IndicesRecoveryForAllAsync(Func requestParameters = null) + public Task> IndicesRecoveryForAllAsync(Func requestParameters = null) { var url = "_recovery"; IRequestParameters requestParams = null; if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20385,14 +20385,14 @@ public Task> IndicesRecoveryForAllAsync(Func - i.e result.Response.hits.hits[0].property.nested["nested_deeper"] /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - public ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null) + public ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null) { var url = "_recovery"; IRequestParameters requestParams = null; if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20419,14 +20419,14 @@ public ElasticsearchResponse IndicesRecoveryForAll(Func - i.e result.Response.hits.hits[0].property.nested["nested_deeper"] /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - public Task> IndicesRecoveryForAllAsync(Func requestParameters = null) + public Task> IndicesRecoveryForAllAsync(Func requestParameters = null) { var url = "_recovery"; IRequestParameters requestParams = null; if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20452,7 +20452,7 @@ public Task> IndicesRecoveryForAllAsync /// - If T is of type byte[] deserialization will be shortcircuited /// - If T is of type VoidResponse the response stream will be ignored completely /// - public ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null) + public ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null) { index.ThrowIfNullOrEmpty("index"); var url = "{0}/_recovery".F(Encoded(index)); @@ -20460,7 +20460,7 @@ public ElasticsearchResponse IndicesRecovery(string index, Func IndicesRecovery(string index, Func - If T is of type byte[] deserialization will be shortcircuited /// - If T is of type VoidResponse the response stream will be ignored completely /// - public Task> IndicesRecoveryAsync(string index, Func requestParameters = null) + public Task> IndicesRecoveryAsync(string index, Func requestParameters = null) { index.ThrowIfNullOrEmpty("index"); var url = "{0}/_recovery".F(Encoded(index)); @@ -20494,7 +20494,7 @@ public Task> IndicesRecoveryAsync(string index, Func if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20522,7 +20522,7 @@ public Task> IndicesRecoveryAsync(string index, Func /// - i.e result.Response.hits.hits[0].property.nested["nested_deeper"] /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - public ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null) + public ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null) { index.ThrowIfNullOrEmpty("index"); var url = "{0}/_recovery".F(Encoded(index)); @@ -20530,7 +20530,7 @@ public ElasticsearchResponse IndicesRecovery(string index, Fu if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } @@ -20558,7 +20558,7 @@ public ElasticsearchResponse IndicesRecovery(string index, Fu /// - i.e result.Response.hits.hits[0].property.nested["nested_deeper"] /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - public Task> IndicesRecoveryAsync(string index, Func requestParameters = null) + public Task> IndicesRecoveryAsync(string index, Func requestParameters = null) { index.ThrowIfNullOrEmpty("index"); var url = "{0}/_recovery".F(Encoded(index)); @@ -20566,7 +20566,7 @@ public Task> IndicesRecoveryAsync(strin if (requestParameters != null) { - requestParams = requestParameters(new IndicesRecoveryRequestParameters()); + requestParams = requestParameters(new RecoveryStatusRequestParameters()); } diff --git a/src/Elasticsearch.Net/IElasticsearchClient.Generated.cs b/src/Elasticsearch.Net/IElasticsearchClient.Generated.cs index 9122c685abf..ddbc7d41e58 100644 --- a/src/Elasticsearch.Net/IElasticsearchClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticsearchClient.Generated.cs @@ -10763,7 +10763,7 @@ public interface IElasticsearchClient /// - If T is of type VoidResponse the response stream will be ignored completely /// - ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null); + ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null); ///Represents a GET on /_recovery ///Returns: A task that'll return an ElasticsearchResponse<T> holding the reponse body deserialized as T. @@ -10780,7 +10780,7 @@ public interface IElasticsearchClient /// - If T is of type VoidResponse the response stream will be ignored completely /// - Task> IndicesRecoveryForAllAsync(Func requestParameters = null); + Task> IndicesRecoveryForAllAsync(Func requestParameters = null); ///Represents a GET on /_recovery ///Returns: ElasticsearchResponse<T> holding the response body deserialized as DynamicDictionary @@ -10799,7 +10799,7 @@ public interface IElasticsearchClient /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null); + ElasticsearchResponse IndicesRecoveryForAll(Func requestParameters = null); ///Represents a GET on /_recovery ///Returns: Task that'll return an ElasticsearchResponse<T$gt; holding the response body deserialized as DynamicDictionary @@ -10818,7 +10818,7 @@ public interface IElasticsearchClient /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - Task> IndicesRecoveryForAllAsync(Func requestParameters = null); + Task> IndicesRecoveryForAllAsync(Func requestParameters = null); ///Represents a GET on /{index}/_recovery ///Returns: ElasticsearchResponse<T> holding the reponse body deserialized as T. @@ -10836,7 +10836,7 @@ public interface IElasticsearchClient /// - If T is of type VoidResponse the response stream will be ignored completely /// - ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null); + ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null); ///Represents a GET on /{index}/_recovery ///Returns: A task that'll return an ElasticsearchResponse<T> holding the reponse body deserialized as T. @@ -10854,7 +10854,7 @@ public interface IElasticsearchClient /// - If T is of type VoidResponse the response stream will be ignored completely /// - Task> IndicesRecoveryAsync(string index, Func requestParameters = null); + Task> IndicesRecoveryAsync(string index, Func requestParameters = null); ///Represents a GET on /{index}/_recovery ///Returns: ElasticsearchResponse<T> holding the response body deserialized as DynamicDictionary @@ -10874,7 +10874,7 @@ public interface IElasticsearchClient /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null); + ElasticsearchResponse IndicesRecovery(string index, Func requestParameters = null); ///Represents a GET on /{index}/_recovery ///Returns: Task that'll return an ElasticsearchResponse<T$gt; holding the response body deserialized as DynamicDictionary @@ -10894,7 +10894,7 @@ public interface IElasticsearchClient /// - can be safely dispatched to a nullable type even if intermediate properties do not exist /// - Task> IndicesRecoveryAsync(string index, Func requestParameters = null); + Task> IndicesRecoveryAsync(string index, Func requestParameters = null); ///Represents a POST on /_refresh ///Returns: ElasticsearchResponse<T> holding the reponse body deserialized as T. diff --git a/src/Elasticsearch.Net/Obsolete/IndicesRecoveryStatus.cs b/src/Elasticsearch.Net/Obsolete/IndicesRecoveryStatus.cs new file mode 100644 index 00000000000..d47a120257c --- /dev/null +++ b/src/Elasticsearch.Net/Obsolete/IndicesRecoveryStatus.cs @@ -0,0 +1,76 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Elasticsearch.Net +{ +#pragma warning disable 0618 + using IndicesRecoveryStatusSelector = Func; +#pragma warning restore 0618 + + [Obsolete("Scheduled to be removed in 2.0, renamed to TypeExistsRequestParameters")] + public class IndicesRecoveryRequestParameters : RecoveryStatusRequestParameters { } + + public static class IndicesRecoveryStatusClientExtensions + { + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static ElasticsearchResponse IndicesRecoveryForAll(this IElasticsearchClient client, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryForAll(selector); + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static Task> IndicesRecoveryForAllAsync(this IElasticsearchClient client, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryForAllAsync(selector); + + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static ElasticsearchResponse IndicesRecoveryForAll(this IElasticsearchClient client, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryForAll(selector); + + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static Task> IndicesRecoveryForAllAsync(this IElasticsearchClient client, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryForAllAsync(selector); + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static ElasticsearchResponse IndicesRecovery(this IElasticsearchClient client, string index, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecovery(index, selector); + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static Task> IndicesRecoveryAsync(this IElasticsearchClient client, string index, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryAsync(index, selector); + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static ElasticsearchResponse IndicesRecovery(this IElasticsearchClient client, string index, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecovery(index, selector); + } + + [Obsolete("Scheduled to be removed in 2.0, use the method that takes a Func of RecoveryStatusRequestParameters")] + public static Task> IndicesRecoveryAsync(this IElasticsearchClient client, string index, IndicesRecoveryStatusSelector requestParameters = null) + { + var selector = Obsolete.UpCastSelector(requestParameters); + return client.IndicesRecoveryAsync(index, selector); + } + } +} diff --git a/src/Nest/DSL/RecoveryStatusDescriptor.cs b/src/Nest/DSL/RecoveryStatusDescriptor.cs new file mode 100644 index 00000000000..e9d36f1e476 --- /dev/null +++ b/src/Nest/DSL/RecoveryStatusDescriptor.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Elasticsearch.Net; +using Newtonsoft.Json; + +namespace Nest +{ + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + public interface IRecoveryStatusRequest : IIndicesOptionalPath { } + + internal static class RecoveryStatusPathInfo + { + public static void Update(ElasticsearchPathInfo pathInfo, IRecoveryStatusRequest request) + { + pathInfo.HttpMethod = PathInfoHttpMethod.GET; + } + } + + public partial class RecoveryStatusRequest : IndicesOptionalPathBase, IRecoveryStatusRequest + { + protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo pathInfo) + { + RecoveryStatusPathInfo.Update(pathInfo, this); + } + } + + [DescriptorFor("IndicesRecovery")] + public partial class RecoveryStatusDescriptor : IndicesOptionalPathDescriptor, IRecoveryStatusRequest + { + protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo pathInfo) + { + RecoveryStatusPathInfo.Update(pathInfo, this); + } + } +} diff --git a/src/Nest/DSL/_Descriptors.generated.cs b/src/Nest/DSL/_Descriptors.generated.cs index 6d38d281adf..d851bd1a4f2 100644 --- a/src/Nest/DSL/_Descriptors.generated.cs +++ b/src/Nest/DSL/_Descriptors.generated.cs @@ -3426,13 +3426,13 @@ public PutWarmerDescriptor ExpandWildcards(ExpandWildcards expand_wildcards) ///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-recovery.html /// /// - public partial class IndicesRecoveryDescriptor : BaseRequest + public partial class RecoveryStatusDescriptor { ///Whether to display detailed information about shard recovery - public IndicesRecoveryDescriptor Detailed(bool detailed = true) + public RecoveryStatusDescriptor Detailed(bool detailed = true) { this.Request.RequestParameters.Detailed(detailed); return this; @@ -3440,7 +3440,7 @@ public IndicesRecoveryDescriptor Detailed(bool detailed = true) ///Display only those recoveries that are currently on-going - public IndicesRecoveryDescriptor ActiveOnly(bool active_only = true) + public RecoveryStatusDescriptor ActiveOnly(bool active_only = true) { this.Request.RequestParameters.ActiveOnly(active_only); return this; @@ -3448,18 +3448,12 @@ public IndicesRecoveryDescriptor ActiveOnly(bool active_only = true) ///Whether to return time and byte values in human-readable format. - public IndicesRecoveryDescriptor Human(bool human = true) + public RecoveryStatusDescriptor Human(bool human = true) { this.Request.RequestParameters.Human(human); return this; } - - protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo pathInfo) - { - throw new NotImplementedException(); - } - } diff --git a/src/Nest/DSL/_Requests.generated.cs b/src/Nest/DSL/_Requests.generated.cs index bafcba1be34..d7be12cd6f8 100644 --- a/src/Nest/DSL/_Requests.generated.cs +++ b/src/Nest/DSL/_Requests.generated.cs @@ -3126,7 +3126,7 @@ public ExpandWildcards ExpandWildcards ///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-recovery.html /// /// - public partial class IndicesRecoveryRequest : BasePathRequest + public partial class RecoveryStatusRequest { ///Whether to display detailed information about shard recovery @@ -3152,12 +3152,6 @@ public bool Human set { this.Request.RequestParameters.AddQueryString("human", value); } } - - protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo pathInfo) - { - throw new NotImplementedException(); - } - } diff --git a/src/Nest/Domain/Recovery/RecoveryBytes.cs b/src/Nest/Domain/Recovery/RecoveryBytes.cs new file mode 100644 index 00000000000..704ff3f07ae --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryBytes.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryBytes + { + + [JsonProperty("total")] + public long Total { get; internal set; } + + [JsonProperty("reused")] + public long Reused { get; internal set; } + + [JsonProperty("recovered")] + public long Recovered { get; internal set; } + + [JsonProperty("percent")] + public string Percent { get; internal set; } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryFileDetails.cs b/src/Nest/Domain/Recovery/RecoveryFileDetails.cs new file mode 100644 index 00000000000..1903017b59a --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryFileDetails.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryFileDetails + { + [JsonProperty("name")] + public string Name { get; internal set; } + + [JsonProperty("length")] + public long Length { get; internal set; } + + [JsonProperty("recovered")] + public long Recovered { get; internal set; } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryFiles.cs b/src/Nest/Domain/Recovery/RecoveryFiles.cs new file mode 100644 index 00000000000..e7ecf49f2cd --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryFiles.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryFiles + { + [JsonProperty("total")] + public long Total { get; internal set; } + + [JsonProperty("reused")] + public long Reused { get; internal set; } + + [JsonProperty("recovered")] + public long Recovered { get; internal set; } + + [JsonProperty("percent")] + public string Percent { get; internal set; } + + [JsonProperty("details")] + public IEnumerable Details { get; internal set; } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryIndexStatus.cs b/src/Nest/Domain/Recovery/RecoveryIndexStatus.cs new file mode 100644 index 00000000000..ddff0dcc719 --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryIndexStatus.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryIndexStatus + { + [JsonProperty("total_time_in_millis")] + public long TotalTimeInMilliseconds { get; internal set; } + + [JsonProperty("bytes")] + public RecoveryBytes Bytes { get; internal set; } + + [JsonProperty("files")] + public RecoveryFiles Files { get; internal set; } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryOrigin.cs b/src/Nest/Domain/Recovery/RecoveryOrigin.cs new file mode 100644 index 00000000000..5318a9d2f94 --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryOrigin.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryOrigin + { + [JsonProperty("id")] + public string Id { get; internal set; } + + [JsonProperty("hostname")] + public string HostName { get; internal set; } + + [JsonProperty("ip")] + public string Ip { get; internal set; } + + [JsonProperty("name")] + public string Name { get; internal set; } + + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryStartStatus.cs b/src/Nest/Domain/Recovery/RecoveryStartStatus.cs new file mode 100644 index 00000000000..5fdc8f03aca --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryStartStatus.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryStartStatus + { + [JsonProperty("check_index_time")] + public long CheckIndexTime { get; internal set; } + + [JsonProperty("total_time_in_millis")] + public string TotalTimeInMilliseconds { get; internal set; } + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryStatus.cs b/src/Nest/Domain/Recovery/RecoveryStatus.cs new file mode 100644 index 00000000000..8aa76f2c2a9 --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryStatus.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryStatus + { + [JsonProperty("shards")] + public IEnumerable Shards { get; internal set; } + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Recovery/RecoveryTranslogStatus.cs b/src/Nest/Domain/Recovery/RecoveryTranslogStatus.cs new file mode 100644 index 00000000000..262de496b1d --- /dev/null +++ b/src/Nest/Domain/Recovery/RecoveryTranslogStatus.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Nest +{ + public class RecoveryTranslogStatus + { + [JsonProperty("recovered")] + public long Recovered { get; internal set; } + + [JsonProperty("total_time_in_millis")] + public string TotalTimeInMilliseconds { get; internal set; } + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Responses/RecoveryStatusResponse.cs b/src/Nest/Domain/Responses/RecoveryStatusResponse.cs new file mode 100644 index 00000000000..8f137d1958c --- /dev/null +++ b/src/Nest/Domain/Responses/RecoveryStatusResponse.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IRecoveryStatusResponse : IResponse + { + Dictionary Indices { get; set; } + } + + [JsonObject] + public class RecoveryStatusResponse : BaseResponse, IRecoveryStatusResponse + { + + [JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))] + public Dictionary Indices { get; set; } + } +} \ No newline at end of file diff --git a/src/Nest/Domain/Responses/ShardRecovery.cs b/src/Nest/Domain/Responses/ShardRecovery.cs new file mode 100644 index 00000000000..371140b6d8c --- /dev/null +++ b/src/Nest/Domain/Responses/ShardRecovery.cs @@ -0,0 +1,44 @@ +using System; +using Newtonsoft.Json; + +namespace Nest +{ + public class ShardRecovery + { + [JsonProperty("id")] + public long Id { get; internal set; } + + [JsonProperty("type")] + public string Type { get; internal set; } + + [JsonProperty("stage")] + public string Stage { get; internal set; } + + [JsonProperty("primary")] + public bool Primary { get; internal set; } + + [JsonProperty("start_time")] + public DateTime? StartTime { get; internal set; } + + [JsonProperty("stop_time")] + public DateTime? StopTime { get; internal set; } + + [JsonProperty("total_time_in_millis")] + public long TotalTimeInMilliseconds { get; internal set; } + + [JsonProperty("source")] + public RecoveryOrigin Source { get; internal set; } + + [JsonProperty("target")] + public RecoveryOrigin Target { get; internal set; } + + [JsonProperty("index")] + public RecoveryIndexStatus Index { get; internal set; } + + [JsonProperty("translog")] + public RecoveryTranslogStatus Translog { get; internal set; } + + [JsonProperty("start")] + public RecoveryStartStatus Start { get; internal set; } + } +} \ No newline at end of file diff --git a/src/Nest/ElasticClient-RecoveryStatus.cs b/src/Nest/ElasticClient-RecoveryStatus.cs new file mode 100644 index 00000000000..08e7b666561 --- /dev/null +++ b/src/Nest/ElasticClient-RecoveryStatus.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + using RecoveryStatusConverter = Func; + + public partial class ElasticClient + { + /// + public IRecoveryStatusResponse RecoveryStatus(Func selector = null) + { + selector = selector ?? (s => s); + return this.Dispatch( + selector, + (p, d) => this.RawDispatch.IndicesRecoveryDispatch( + p.DeserializationState(new RecoveryStatusConverter(DeserializeRecoveryStatusResponse)) + ) + ); + } + + /// + public IRecoveryStatusResponse RecoveryStatus(IRecoveryStatusRequest statusRequest) + { + return this.Dispatch( + statusRequest, + (p, d) => this.RawDispatch.IndicesRecoveryDispatch( + p.DeserializationState(new RecoveryStatusConverter(DeserializeRecoveryStatusResponse)) + ) + ); + } + + /// + public Task RecoveryStatusAsync(Func selector = null) + { + selector = selector ?? (s => s); + return this.DispatchAsync( + selector, + (p, d) => this.RawDispatch.IndicesRecoveryDispatchAsync( + p.DeserializationState(new RecoveryStatusConverter(DeserializeRecoveryStatusResponse)) + ) + ); + } + + /// + public Task RecoveryStatusAsync(IRecoveryStatusRequest statusRequest) + { + return this.DispatchAsync( + statusRequest, + (p, d) => this.RawDispatch.IndicesRecoveryDispatchAsync( + p.DeserializationState(new RecoveryStatusConverter(DeserializeRecoveryStatusResponse)) + ) + ); + } + + private RecoveryStatusResponse DeserializeRecoveryStatusResponse(IElasticsearchResponse response, Stream stream) + { + if (!response.Success) return CreateInvalidInstance(response); + var indices = this.Serializer.Deserialize>(stream); + return new RecoveryStatusResponse { IsValid = true, Indices = indices }; + } + } +} \ No newline at end of file diff --git a/src/Nest/IElasticClient.cs b/src/Nest/IElasticClient.cs index c5350819b77..a60b67670dc 100644 --- a/src/Nest/IElasticClient.cs +++ b/src/Nest/IElasticClient.cs @@ -1379,5 +1379,17 @@ Task GetFieldMappingAsync(Func Task PingAsync(IPingRequest pingRequest); + + /// + IRecoveryStatusResponse RecoveryStatus(Func selector = null); + + /// + IRecoveryStatusResponse RecoveryStatus(IRecoveryStatusRequest statusRequest); + + /// + Task RecoveryStatusAsync(Func selector = null); + + /// + Task RecoveryStatusAsync(IRecoveryStatusRequest statusRequest); } } diff --git a/src/Nest/Nest.csproj b/src/Nest/Nest.csproj index 1bd5fd157d2..6797ebb35d5 100644 --- a/src/Nest/Nest.csproj +++ b/src/Nest/Nest.csproj @@ -185,6 +185,16 @@ + + + + + + + + + + @@ -209,6 +219,7 @@ + @@ -299,6 +310,7 @@ + diff --git a/src/Nest/Obsolete/Obsolete.cs b/src/Nest/Obsolete/Obsolete.cs index e916ff174cd..b4462b3b90d 100644 --- a/src/Nest/Obsolete/Obsolete.cs +++ b/src/Nest/Obsolete/Obsolete.cs @@ -53,4 +53,10 @@ public class MpercolateDescriptor : MultiPercolateDescriptor { } [Obsolete("Scheduled to be removed in 2.0, use MultiPercolateRequest instead")] public class MpercolateRequest : MultiPercolateRequest {} + + [Obsolete("Scheduled to be removed in 2.0, use RecoveryStatusDescriptor instead")] + public class IndicesRecoveryDescriptor : RecoveryStatusDescriptor { } + + [Obsolete("Scheduled to be removed in 2.0, use RecoveryStatusRequest instead")] + public class IndicesRecoveryRequest : RecoveryStatusRequest {} } diff --git a/src/Nest/RawDispatch.generated.cs b/src/Nest/RawDispatch.generated.cs index 27ca7155806..354b10d3ef0 100644 --- a/src/Nest/RawDispatch.generated.cs +++ b/src/Nest/RawDispatch.generated.cs @@ -2262,7 +2262,7 @@ internal Task> IndicesPutWarmerDispatchAsync(Elastic } - internal ElasticsearchResponse IndicesRecoveryDispatch(ElasticsearchPathInfo pathInfo ) + internal ElasticsearchResponse IndicesRecoveryDispatch(ElasticsearchPathInfo pathInfo ) { switch(pathInfo.HttpMethod) { @@ -2278,7 +2278,7 @@ internal ElasticsearchResponse IndicesRecoveryDispatch(ElasticsearchPathIn } - internal Task> IndicesRecoveryDispatchAsync(ElasticsearchPathInfo pathInfo ) + internal Task> IndicesRecoveryDispatchAsync(ElasticsearchPathInfo pathInfo ) { switch(pathInfo.HttpMethod) { diff --git a/src/Tests/Nest.Tests.Integration/Core/Repository/RestoreStatusTests.cs b/src/Tests/Nest.Tests.Integration/Core/Repository/RestoreStatusTests.cs new file mode 100644 index 00000000000..8060c9315f7 --- /dev/null +++ b/src/Tests/Nest.Tests.Integration/Core/Repository/RestoreStatusTests.cs @@ -0,0 +1,81 @@ +using System; +using System.Linq; +using FluentAssertions; +using NUnit.Framework; +using Nest.Tests.MockData.Domain; + +namespace Nest.Tests.Integration.Core.Repository +{ + [TestFixture] + public class RestoreStatusTests : IntegrationTests + { + [Test] + public void SnapshotRestore() + { + var indexName = ElasticsearchConfiguration.NewUniqueIndexName(); + var repositoryName = ElasticsearchConfiguration.NewUniqueIndexName(); + var elasticsearchProject = new ElasticsearchProject() + { + Id = 1337, + Name = "Coboles", + Content = "COBOL elasticsearch client" + }; + Client.Index(elasticsearchProject, i => i.Index(indexName).Refresh(true)); + + + var createReposResult = this.Client.CreateRepository(repositoryName, r => r + .FileSystem(@"local\\path", o => o + .Compress() + .ConcurrentStreams(10) + ) + ); + createReposResult.IsValid.Should().BeTrue(); + createReposResult.Acknowledged.Should().BeTrue(); + + var backupName = ElasticsearchConfiguration.NewUniqueIndexName(); + var snapshotResponse = this.Client.Snapshot(repositoryName, backupName, selector: f => f + .Index(indexName) + .WaitForCompletion(true) + .IgnoreUnavailable() + .Partial()); + snapshotResponse.IsValid.Should().BeTrue(); + snapshotResponse.Accepted.Should().BeTrue(); + snapshotResponse.Snapshot.Should().NotBeNull(); + snapshotResponse.Snapshot.EndTimeInMilliseconds.Should().BeGreaterThan(0); + snapshotResponse.Snapshot.StartTime.Should().BeAfter(DateTime.UtcNow.AddDays(-1)); + + var d = ElasticsearchConfiguration.DefaultIndex; + var restoreResponse = this.Client.Restore(repositoryName, backupName, r => r + .RenamePattern(d + "_(.+)") + .RenameReplacement(d + "_restored_$1") + .Index(indexName) + .IgnoreUnavailable(true)); + + var restoredIndexName = indexName.Replace(d + "_", d + "_restored_"); + restoreResponse.IsValid.Should().BeTrue(); + + var recovered = false; + do + { + + var restoreStatus = this.Client.RecoveryStatus(s => s.Index(indexName)); + restoreStatus.Should().NotBeNull(); + restoreStatus.IsValid.Should().BeTrue(); + restoreStatus.Indices.Should().NotBeEmpty().And.ContainKey(indexName); + var indexRecovery = restoreStatus.Indices[indexName]; + indexRecovery.Shards.Should().NotBeEmpty(); + + var firstShard = indexRecovery.Shards.First(); + firstShard.Source.Name.Should().NotBeNullOrWhiteSpace(); + firstShard.Target.Name.Should().NotBeNullOrWhiteSpace(); + recovered = indexRecovery.Shards.All(s => s.Stage == "DONE"); + + } while (!recovered); + + var deleteReposResult = this.Client.DeleteRepository(repositoryName); + deleteReposResult.IsValid.Should().BeTrue(); + deleteReposResult.Acknowledged.Should().BeTrue(); + } + + } +} diff --git a/src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj b/src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj index a953583c60a..ec8fb75c09f 100644 --- a/src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj +++ b/src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj @@ -115,6 +115,7 @@ +