Skip to content

Commit 0afe4fd

Browse files
russcamMpdreamz
authored andcommitted
Add include_aliases and partial to Snapshot Restore request (#3380)
Closes #3340
1 parent 0f6aac0 commit 0afe4fd

File tree

1 file changed

+91
-2
lines changed

1 file changed

+91
-2
lines changed

src/Nest/Modules/SnapshotAndRestore/Restore/RestoreRequest.cs

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,111 @@
44

55
namespace Nest
66
{
7+
/// <summary>
8+
/// Restores a snapshot
9+
/// </summary>
710
public partial interface IRestoreRequest
811
{
12+
/// <summary>
13+
/// The indices to restore
14+
/// </summary>
915
[JsonProperty("indices")]
1016
Indices Indices { get; set; }
17+
18+
/// <summary>
19+
/// Whether indices specified that do not exist
20+
/// should be ignored.
21+
/// </summary>
1122
[JsonProperty("ignore_unavailable")]
1223
bool? IgnoreUnavailable { get; set; }
24+
25+
/// <summary>
26+
/// Whether the cluster global state should be included
27+
/// </summary>
1328
[JsonProperty("include_global_state")]
1429
bool? IncludeGlobalState { get; set; }
30+
31+
/// <summary>
32+
/// A pattern to use to rename restored indices. The pattern
33+
/// can be used to capture parts of the original index name
34+
/// and used within <see cref="RenameReplacement"/>
35+
/// </summary>
1536
[JsonProperty("rename_pattern")]
1637
string RenamePattern { get; set; }
38+
39+
/// <summary>
40+
/// A replacement to use to rename restored indices. Used
41+
/// in conjunction with <see cref="RenamePattern"/>.
42+
/// </summary>
1743
[JsonProperty("rename_replacement")]
1844
string RenameReplacement { get; set; }
45+
46+
/// <summary>
47+
/// The index settings that should be applied as part of
48+
/// the restore operation. Some settings cannot be changed
49+
/// as part of a restore operation, for example, the number
50+
/// of shards.
51+
/// </summary>
1952
[JsonProperty("index_settings")]
2053
IUpdateIndexSettingsRequest IndexSettings { get; set; }
54+
55+
/// <summary>
56+
/// The index settings to ignore as part of the restore operation
57+
/// </summary>
2158
[JsonProperty("ignore_index_settings")]
2259
List<string> IgnoreIndexSettings { get; set; }
23-
}
2460

61+
/// <summary>
62+
/// Whether to include aliases as part of the restore
63+
/// </summary>
64+
[JsonProperty("include_aliases")]
65+
bool? IncludeAliases { get; set; }
66+
67+
/// <summary>
68+
/// Allow partial restore for indices that don't have snapshots of all shards available.
69+
/// <para />
70+
/// By default, the entire restore operation will fail if one or more indices participating
71+
/// in the operation don’t have snapshots of all shards available. It can occur if some
72+
/// shards failed to snapshot for example. It is still possible to restore such indices
73+
/// by setting <see cref="Partial"/> to <c>true</c>. Only successfully snapshotted shards
74+
/// will be restored in this case and all missing shards will be recreated empty.
75+
/// </summary>
76+
[JsonProperty("partial")]
77+
bool? Partial { get; set; }
78+
}
79+
80+
/// <inheritdoc cref="IRestoreRequest"/>
2581
public partial class RestoreRequest
2682
{
83+
/// <inheritdoc />
2784
public Indices Indices { get; set; }
2885

86+
/// <inheritdoc />
2987
public bool? IgnoreUnavailable { get; set; }
3088

89+
/// <inheritdoc />
3190
public bool? IncludeGlobalState { get; set; }
3291

92+
/// <inheritdoc />
3393
public string RenamePattern { get; set; }
3494

95+
/// <inheritdoc />
3596
public string RenameReplacement { get; set; }
97+
98+
/// <inheritdoc />
3699
public IUpdateIndexSettingsRequest IndexSettings { get; set; }
100+
101+
/// <inheritdoc />
37102
public List<string> IgnoreIndexSettings { get; set; }
103+
104+
/// <inheritdoc />
105+
public bool? IncludeAliases { get; set; }
106+
107+
/// <inheritdoc />
108+
public bool? Partial { get; set; }
38109
}
39110

111+
/// <inheritdoc cref="IRestoreRequest"/>
40112
[DescriptorFor("SnapshotRestore")]
41113
public partial class RestoreDescriptor
42114
{
@@ -47,27 +119,44 @@ public partial class RestoreDescriptor
47119
string IRestoreRequest.RenameReplacement { get; set; }
48120
IUpdateIndexSettingsRequest IRestoreRequest.IndexSettings { get; set; }
49121
List<string> IRestoreRequest.IgnoreIndexSettings { get; set; }
122+
bool? IRestoreRequest.IncludeAliases { get; set; }
123+
bool? IRestoreRequest.Partial { get; set; }
50124

125+
/// <inheritdoc cref="IRestoreRequest.Indices"/>
51126
public RestoreDescriptor Index(IndexName index) => this.Indices(index);
52127

128+
/// <inheritdoc cref="IRestoreRequest.Indices"/>
53129
public RestoreDescriptor Index<T>() where T : class => this.Indices(typeof(T));
54130

131+
/// <inheritdoc cref="IRestoreRequest.Indices"/>
55132
public RestoreDescriptor Indices(Indices indices) => Assign(a => a.Indices = indices);
56133

134+
/// <inheritdoc cref="IRestoreRequest.IgnoreUnavailable"/>
57135
public RestoreDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Assign(a => a.IgnoreUnavailable = ignoreUnavailable);
58136

137+
/// <inheritdoc cref="IRestoreRequest.IncludeGlobalState"/>
59138
public RestoreDescriptor IncludeGlobalState(bool? includeGlobalState = true) => Assign(a => a.IncludeGlobalState = includeGlobalState);
60139

140+
/// <inheritdoc cref="IRestoreRequest.RenamePattern"/>
61141
public RestoreDescriptor RenamePattern(string renamePattern) => Assign(a => a.RenamePattern = renamePattern);
62142

143+
/// <inheritdoc cref="IRestoreRequest.RenameReplacement"/>
63144
public RestoreDescriptor RenameReplacement(string renameReplacement) => Assign(a => a.RenameReplacement = renameReplacement);
64145

146+
/// <inheritdoc cref="IRestoreRequest.IndexSettings"/>
65147
public RestoreDescriptor IndexSettings(Func<UpdateIndexSettingsDescriptor, IUpdateIndexSettingsRequest> settingsSelector) =>
66148
Assign(a => a.IndexSettings = settingsSelector?.Invoke(new UpdateIndexSettingsDescriptor()));
67149

150+
/// <inheritdoc cref="IRestoreRequest.IgnoreIndexSettings"/>
68151
public RestoreDescriptor IgnoreIndexSettings(List<string> ignoreIndexSettings) => Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings);
69152

70-
public RestoreDescriptor IgnoreIndexSettings(params string[] ignoreIndexSettings) =>Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings.ToListOrNullIfEmpty());
153+
/// <inheritdoc cref="IRestoreRequest.IgnoreIndexSettings"/>
154+
public RestoreDescriptor IgnoreIndexSettings(params string[] ignoreIndexSettings) => Assign(a => a.IgnoreIndexSettings = ignoreIndexSettings.ToListOrNullIfEmpty());
155+
156+
/// <inheritdoc cref="IRestoreRequest.IncludeAliases"/>
157+
public RestoreDescriptor IncludeAliases(bool? includeAliases = true) => Assign(a => a.IncludeAliases = includeAliases);
71158

159+
/// <inheritdoc cref="IRestoreRequest.Partial"/>
160+
public RestoreDescriptor Partial(bool? partial = true) => Assign(a => a.Partial = partial);
72161
}
73162
}

0 commit comments

Comments
 (0)