From 734667b700005a1f396f00b30e3823be7b606044 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Mon, 27 Aug 2018 14:45:18 +1000 Subject: [PATCH] Add include_aliases and partial to Snapshot Restore request Closes #3340 --- .../Restore/RestoreRequest.cs | 93 ++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/src/Nest/Modules/SnapshotAndRestore/Restore/RestoreRequest.cs b/src/Nest/Modules/SnapshotAndRestore/Restore/RestoreRequest.cs index cfb26a06d52..0a72b3d8ee6 100644 --- a/src/Nest/Modules/SnapshotAndRestore/Restore/RestoreRequest.cs +++ b/src/Nest/Modules/SnapshotAndRestore/Restore/RestoreRequest.cs @@ -4,39 +4,111 @@ namespace Nest { + /// + /// Restores a snapshot + /// public partial interface IRestoreRequest { + /// + /// The indices to restore + /// [JsonProperty("indices")] Indices Indices { get; set; } + + /// + /// Whether indices specified that do not exist + /// should be ignored. + /// [JsonProperty("ignore_unavailable")] bool? IgnoreUnavailable { get; set; } + + /// + /// Whether the cluster global state should be included + /// [JsonProperty("include_global_state")] bool? IncludeGlobalState { get; set; } + + /// + /// A pattern to use to rename restored indices. The pattern + /// can be used to capture parts of the original index name + /// and used within + /// [JsonProperty("rename_pattern")] string RenamePattern { get; set; } + + /// + /// A replacement to use to rename restored indices. Used + /// in conjunction with . + /// [JsonProperty("rename_replacement")] string RenameReplacement { get; set; } + + /// + /// The index settings that should be applied as part of + /// the restore operation. Some settings cannot be changed + /// as part of a restore operation, for example, the number + /// of shards. + /// [JsonProperty("index_settings")] IUpdateIndexSettingsRequest IndexSettings { get; set; } + + /// + /// The index settings to ignore as part of the restore operation + /// [JsonProperty("ignore_index_settings")] List IgnoreIndexSettings { get; set; } - } + /// + /// Whether to include aliases as part of the restore + /// + [JsonProperty("include_aliases")] + bool? IncludeAliases { get; set; } + + /// + /// Allow partial restore for indices that don't have snapshots of all shards available. + /// + /// By default, the entire restore operation will fail if one or more indices participating + /// in the operation don’t have snapshots of all shards available. It can occur if some + /// shards failed to snapshot for example. It is still possible to restore such indices + /// by setting to true. Only successfully snapshotted shards + /// will be restored in this case and all missing shards will be recreated empty. + /// + [JsonProperty("partial")] + bool? Partial { get; set; } + } + + /// public partial class RestoreRequest { + /// public Indices Indices { get; set; } + /// public bool? IgnoreUnavailable { get; set; } + /// public bool? IncludeGlobalState { get; set; } + /// public string RenamePattern { get; set; } + /// public string RenameReplacement { get; set; } + + /// public IUpdateIndexSettingsRequest IndexSettings { get; set; } + + /// public List IgnoreIndexSettings { get; set; } + + /// + public bool? IncludeAliases { get; set; } + + /// + public bool? Partial { get; set; } } + /// [DescriptorFor("SnapshotRestore")] public partial class RestoreDescriptor { @@ -47,27 +119,44 @@ public partial class RestoreDescriptor string IRestoreRequest.RenameReplacement { get; set; } IUpdateIndexSettingsRequest IRestoreRequest.IndexSettings { get; set; } List IRestoreRequest.IgnoreIndexSettings { get; set; } + bool? IRestoreRequest.IncludeAliases { get; set; } + bool? IRestoreRequest.Partial { get; set; } + /// public RestoreDescriptor Index(IndexName index) => this.Indices(index); + /// public RestoreDescriptor Index() where T : class => this.Indices(typeof(T)); + /// public RestoreDescriptor Indices(Indices indices) => Assign(a => a.Indices = indices); + /// public RestoreDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Assign(a => a.IgnoreUnavailable = ignoreUnavailable); + /// public RestoreDescriptor IncludeGlobalState(bool? includeGlobalState = true) => Assign(a => a.IncludeGlobalState = includeGlobalState); + /// public RestoreDescriptor RenamePattern(string renamePattern) => Assign(a => a.RenamePattern = renamePattern); + /// public RestoreDescriptor RenameReplacement(string renameReplacement) => Assign(a => a.RenameReplacement = renameReplacement); + /// public RestoreDescriptor IndexSettings(Func settingsSelector) => Assign(a => a.IndexSettings = settingsSelector?.Invoke(new UpdateIndexSettingsDescriptor())); + /// public RestoreDescriptor IgnoreIndexSettings(List ignoreIndexSettings) => Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings); - public RestoreDescriptor IgnoreIndexSettings(params string[] ignoreIndexSettings) =>Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings.ToListOrNullIfEmpty()); + /// + public RestoreDescriptor IgnoreIndexSettings(params string[] ignoreIndexSettings) => Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings.ToListOrNullIfEmpty()); + + /// + public RestoreDescriptor IncludeAliases(bool? includeAliases = true) => Assign(a => a.IncludeAliases = includeAliases); + /// + public RestoreDescriptor Partial(bool? partial = true) => Assign(a => a.Partial = partial); } }