Skip to content

Commit 4f1abc7

Browse files
committed
properly mapped restore response, fix #511 #512 #513 #514 #515 #516 #517
1 parent 9fbf80d commit 4f1abc7

File tree

6 files changed

+57
-9
lines changed

6 files changed

+57
-9
lines changed

Diff for: src/Nest/Domain/Repository/SnapshotRestore.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
5+
namespace Nest
6+
{
7+
public class SnapshotRestore
8+
{
9+
[JsonProperty("snapshot")]
10+
public string Name { get; internal set; }
11+
[JsonProperty("indices")]
12+
public IEnumerable<string> Indices { get; internal set; }
13+
14+
[JsonProperty("shards")]
15+
public ShardsMetaData Shards { get; internal set; }
16+
}
17+
}

Diff for: src/Nest/Domain/Responses/RestoreResponse.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Nest;
6+
using Newtonsoft.Json;
7+
8+
namespace Nest
9+
{
10+
public interface IRestoreResponse : IResponse
11+
{
12+
13+
[JsonProperty("snapshot")]
14+
SnapshotRestore Snapshot { get; set; }
15+
}
16+
17+
[JsonObject]
18+
public class RestoreResponse : BaseResponse, IRestoreResponse
19+
{
20+
21+
[JsonProperty("snapshot")]
22+
public SnapshotRestore Snapshot { get; set; }
23+
24+
}
25+
}

Diff for: src/Nest/ElasticClient-Restore.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ namespace Nest
1010
public partial class ElasticClient
1111
{
1212
/// <inheritdoc />
13-
public IAcknowledgedResponse Restore(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null)
13+
public IRestoreResponse Restore(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null)
1414
{
1515
snapshotName.ThrowIfNullOrEmpty("name");
1616
repository.ThrowIfNullOrEmpty("repository");
1717
selector = selector ?? (s => s);
18-
return this.Dispatch<RestoreDescriptor, RestoreRequestParameters, AcknowledgedResponse>(
18+
return this.Dispatch<RestoreDescriptor, RestoreRequestParameters, RestoreResponse>(
1919
s => selector(s.Snapshot(snapshotName).Repository(repository)),
20-
(p, d) => this.RawDispatch.SnapshotRestoreDispatch<AcknowledgedResponse>(p, d)
20+
(p, d) => this.RawDispatch.SnapshotRestoreDispatch<RestoreResponse>(p, d)
2121
);
2222
}
2323

2424
/// <inheritdoc />
25-
public Task<IAcknowledgedResponse> RestoreAsync(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null)
25+
public Task<IRestoreResponse> RestoreAsync(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null)
2626
{
2727
snapshotName.ThrowIfNullOrEmpty("name");
2828
repository.ThrowIfNullOrEmpty("repository");
2929
selector = selector ?? (s => s);
30-
return this.DispatchAsync<RestoreDescriptor, RestoreRequestParameters, AcknowledgedResponse, IAcknowledgedResponse>(
30+
return this.DispatchAsync<RestoreDescriptor, RestoreRequestParameters, RestoreResponse, IRestoreResponse>(
3131
s => selector(s.Snapshot(snapshotName).Repository(repository)),
32-
(p, d) => this.RawDispatch.SnapshotRestoreDispatchAsync<AcknowledgedResponse>(p, d)
32+
(p, d) => this.RawDispatch.SnapshotRestoreDispatchAsync<RestoreResponse>(p, d)
3333
);
3434
}
3535
}

Diff for: src/Nest/IElasticClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ Task<IExistsResponse> DocumentExistsAsync<T>(Func<DocumentExistsDescriptor<T>, D
11761176
/// <param name="repository">The repository name that holds our snapshot</param>
11771177
/// <param name="snapshotName">The name of the snapshot that we want to restore</param>
11781178
/// <param name="selector">Optionally further describe the restore operation</param>
1179-
IAcknowledgedResponse Restore(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null);
1179+
IRestoreResponse Restore(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null);
11801180

11811181
/// <summary>
11821182
/// Restore a snapshot
@@ -1185,6 +1185,6 @@ Task<IExistsResponse> DocumentExistsAsync<T>(Func<DocumentExistsDescriptor<T>, D
11851185
/// <param name="repository">The repository name that holds our snapshot</param>
11861186
/// <param name="snapshotName">The name of the snapshot that we want to restore</param>
11871187
/// <param name="selector">Optionally further describe the restore operation</param>
1188-
Task<IAcknowledgedResponse> RestoreAsync(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null);
1188+
Task<IRestoreResponse> RestoreAsync(string repository, string snapshotName, Func<RestoreDescriptor, RestoreDescriptor> selector = null);
11891189
}
11901190
}

Diff for: src/Nest/Nest.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@
132132
<Compile Include="Domain\PropertyNameMarker.cs" />
133133
<Compile Include="Domain\PropertyPathMarker.cs" />
134134
<Compile Include="Domain\Repository\Snapshot.cs" />
135+
<Compile Include="Domain\Repository\SnapshotRestore.cs" />
135136
<Compile Include="Domain\Responses\GetSnapshotResponse.cs" />
137+
<Compile Include="Domain\Responses\RestoreResponse.cs" />
136138
<Compile Include="Domain\Responses\SnapshotResponse.cs" />
137139
<Compile Include="DSL\DeleteSnapshotDescriptor.cs" />
138140
<Compile Include="DSL\GetSnapshotDescriptor.cs" />

Diff for: src/Tests/Nest.Tests.Integration/Core/Repository/RestoreTests.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ public void SnapshotRestore()
5454
.Index(indexName)
5555
.IgnoreUnavailable(true));
5656

57-
restoreResponse.IsValid.Should().BeTrue();
5857
var restoredIndexName = indexName.Replace(d + "_", d + "_restored_");
58+
restoreResponse.IsValid.Should().BeTrue();
59+
restoreResponse.Snapshot.Should().NotBeNull();
60+
restoreResponse.Snapshot.Name.Should().Be(backupName);
61+
restoreResponse.Snapshot.Indices.Should().Equal(new string[] { restoredIndexName });
62+
5963
var indexExistsResponse = this._client.IndexExists(f => f.Index(restoredIndexName));
6064
indexExistsResponse.Exists.Should().BeTrue();
6165

0 commit comments

Comments
 (0)