Skip to content

Commit cc7405b

Browse files
committed
Merge branch 'feature/snapshot_status' into develop
2 parents 028aabb + e644680 commit cc7405b

15 files changed

+414
-18
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Elasticsearch.Net;
5+
6+
namespace Nest
7+
{
8+
public interface IRepositorySnapshotOptionalPath<TParameters> : IRequest<TParameters>
9+
where TParameters : IRequestParameters, new()
10+
{
11+
string Repository { get; set; }
12+
string Snapshot { get; set; }
13+
}
14+
15+
internal static class RepositorySnapshotOptionalPathRouteParameters
16+
{
17+
public static void SetRouteParameters<TParameters>(
18+
IRepositorySnapshotOptionalPath<TParameters> path,
19+
IConnectionSettingsValues settings,
20+
ElasticsearchPathInfo<TParameters> pathInfo)
21+
where TParameters : IRequestParameters, new()
22+
{
23+
pathInfo.Repository = path.Repository;
24+
if (!path.Repository.IsNullOrEmpty())
25+
pathInfo.Snapshot = path.Snapshot;
26+
}
27+
28+
}
29+
30+
public abstract class RepositorySnapshotOptionalPathBase<TParameters> : BasePathRequest<TParameters>, IRepositorySnapshotOptionalPath<TParameters>
31+
where TParameters : IRequestParameters, new()
32+
{
33+
public string Repository { get; set; }
34+
35+
public string Snapshot { get; set; }
36+
37+
public RepositorySnapshotOptionalPathBase() {}
38+
39+
public RepositorySnapshotOptionalPathBase(string repository, params string[] snapshots)
40+
{
41+
repository.ThrowIfNullOrEmpty("repository");
42+
this.Repository = repository;
43+
if (snapshots.HasAny())
44+
this.Snapshot = string.Join(",", snapshots);
45+
}
46+
47+
48+
protected override void SetRouteParameters(IConnectionSettingsValues settings, ElasticsearchPathInfo<TParameters> pathInfo)
49+
{
50+
RepositorySnapshotOptionalPathRouteParameters.SetRouteParameters(this, settings, pathInfo);
51+
}
52+
}
53+
/// <summary>
54+
/// Provides a base for descriptors that need to describe a path that contains a
55+
/// <pre>
56+
/// {repository}
57+
/// </pre>
58+
/// routing value
59+
/// </summary>
60+
public abstract class RepositorySnapshotOptionalPathDescriptor<TDescriptor, TParameters>
61+
: BasePathDescriptor<TDescriptor, TParameters>, IRepositorySnapshotOptionalPath<TParameters>
62+
where TDescriptor : RepositorySnapshotOptionalPathDescriptor<TDescriptor, TParameters>
63+
where TParameters : FluentRequestParameters<TParameters>, new()
64+
{
65+
private IRepositorySnapshotOptionalPath<TParameters> Self { get { return this; } }
66+
67+
string IRepositorySnapshotOptionalPath<TParameters>.Repository { get; set; }
68+
69+
string IRepositorySnapshotOptionalPath<TParameters>.Snapshot { get; set; }
70+
71+
/// <summary>
72+
/// Specify the name of the repository we are targeting
73+
/// </summary>
74+
public TDescriptor Repository(string repositoryName)
75+
{
76+
Self.Repository = repositoryName;
77+
return (TDescriptor)this;
78+
}
79+
80+
public TDescriptor Snapshot(string snapshotName)
81+
{
82+
Self.Snapshot = snapshotName;
83+
return (TDescriptor)this;
84+
}
85+
86+
public TDescriptor Snapshots(params string[] snapshots)
87+
{
88+
Self.Snapshot = string.Join(",", snapshots);
89+
return (TDescriptor)this;
90+
}
91+
protected override void SetRouteParameters(IConnectionSettingsValues settings, ElasticsearchPathInfo<TParameters> pathInfo)
92+
{
93+
RepositorySnapshotOptionalPathRouteParameters.SetRouteParameters(this, settings, pathInfo);
94+
}
95+
96+
}
97+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Elasticsearch.Net;
5+
using Newtonsoft.Json;
6+
7+
namespace Nest
8+
{
9+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
10+
public interface ISnapshotStatusRequest : IRepositorySnapshotOptionalPath<SnapshotStatusRequestParameters> { }
11+
12+
internal static class SnapshotStatusPathInfo
13+
{
14+
public static void Update(ElasticsearchPathInfo<SnapshotStatusRequestParameters> pathInfo, ISnapshotStatusRequest request)
15+
{
16+
pathInfo.HttpMethod = PathInfoHttpMethod.GET;
17+
}
18+
}
19+
20+
public partial class SnapshotStatusRequest : RepositorySnapshotOptionalPathBase<SnapshotStatusRequestParameters>, ISnapshotStatusRequest
21+
{
22+
public SnapshotStatusRequest() : base() {}
23+
public SnapshotStatusRequest(string repository, params string[] snapshots) : base(repository, snapshots) { }
24+
25+
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<SnapshotStatusRequestParameters> pathInfo)
26+
{
27+
SnapshotStatusPathInfo.Update(pathInfo, this);
28+
}
29+
}
30+
31+
[DescriptorFor("SnapshotGet")]
32+
public partial class SnapshotStatusDescriptor : RepositorySnapshotOptionalPathDescriptor<SnapshotStatusDescriptor, SnapshotStatusRequestParameters>, ISnapshotStatusRequest
33+
{
34+
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<SnapshotStatusRequestParameters> pathInfo)
35+
{
36+
SnapshotStatusPathInfo.Update(pathInfo, this);
37+
}
38+
39+
}
40+
}

src/Nest/DSL/_Descriptors.generated.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5120,7 +5120,7 @@ public RestoreDescriptor WaitForCompletion(bool wait_for_completion = true)
51205120
///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
51215121
///</pre>
51225122
///</summary>
5123-
public partial class SnapshotStatusDescriptor : BaseRequest<SnapshotStatusRequestParameters>
5123+
public partial class SnapshotStatusDescriptor
51245124
{
51255125

51265126

@@ -5132,12 +5132,6 @@ public SnapshotStatusDescriptor MasterTimeout(string master_timeout)
51325132
return this;
51335133
}
51345134

5135-
5136-
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<SnapshotStatusRequestParameters> pathInfo)
5137-
{
5138-
throw new NotImplementedException();
5139-
}
5140-
51415135

51425136
}
51435137

src/Nest/DSL/_Requests.generated.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,7 +4597,7 @@ public bool WaitForCompletion
45974597
///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
45984598
///</pre>
45994599
///</summary>
4600-
public partial class SnapshotStatusRequest : BasePathRequest<SnapshotStatusRequestParameters>
4600+
public partial class SnapshotStatusRequest
46014601
{
46024602

46034603
///<summary>Explicit operation timeout for connection to master node</summary>
@@ -4607,12 +4607,6 @@ public string MasterTimeout
46074607
set { this.Request.RequestParameters.AddQueryString("master_timeout", value); }
46084608
}
46094609

4610-
4611-
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<SnapshotStatusRequestParameters> pathInfo)
4612-
{
4613-
throw new NotImplementedException();
4614-
}
4615-
46164610
}
46174611

46184612

src/Nest/Domain/Responses/GetSnapshotResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Nest
77
{
88
public interface IGetSnapshotResponse : IResponse
99
{
10-
[JsonProperty("snapshot")]
10+
[JsonProperty("snapshots")]
1111
IEnumerable<Snapshot> Snapshots { get; set; }
1212
}
1313

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Newtonsoft.Json;
5+
6+
namespace Nest
7+
{
8+
public interface ISnapshotStatusResponse : IResponse
9+
{
10+
[JsonProperty("snapshots")]
11+
IEnumerable<SnapshotStatus> Snapshots { get; set; }
12+
}
13+
14+
[JsonObject]
15+
public class SnapshotStatusResponse : BaseResponse, ISnapshotStatusResponse
16+
{
17+
18+
[JsonProperty("snapshots")]
19+
public IEnumerable<SnapshotStatus> Snapshots { get; set; }
20+
21+
}
22+
23+
public class SnapshotStatus
24+
{
25+
[JsonProperty("snapshot")]
26+
public string Snapshot { get; internal set; }
27+
[JsonProperty("repository")]
28+
public string Repository { get; internal set; }
29+
[JsonProperty("state")]
30+
public string State { get; internal set; }
31+
[JsonProperty("shards_stats")]
32+
public SnapshotShardsStats ShardsStats { get; internal set; }
33+
[JsonProperty("stats")]
34+
public SnapshotStats Stats { get; internal set; }
35+
[JsonProperty("indices")]
36+
public IDictionary<string, SnapshotIndexStats> Indices { get; internal set; }
37+
}
38+
39+
public class SnapshotIndexStats
40+
{
41+
[JsonProperty("shards_stats")]
42+
public SnapshotShardsStats ShardsStats { get; internal set; }
43+
[JsonProperty("stats")]
44+
public SnapshotStats Stats { get; internal set; }
45+
[JsonProperty("shards")]
46+
public IDictionary<string, SnapshotShardsStats> Shards { get; internal set; }
47+
}
48+
49+
public class SnapshotIndexShardStats
50+
{
51+
[JsonProperty("stage")]
52+
public string Stage { get; internal set; }
53+
[JsonProperty("node")]
54+
public string Node { get; internal set; }
55+
[JsonProperty("stats")]
56+
public SnapshotStats Stats { get; internal set; }
57+
}
58+
59+
public class SnapshotShardsStats
60+
{
61+
[JsonProperty("initializing")]
62+
public long Initializing { get; internal set; }
63+
[JsonProperty("started")]
64+
public long Started { get; internal set; }
65+
[JsonProperty("finalizing")]
66+
public long Finalizing { get; internal set; }
67+
[JsonProperty("done")]
68+
public long Done { get; internal set; }
69+
[JsonProperty("failed")]
70+
public long Failed { get; internal set; }
71+
[JsonProperty("total")]
72+
public long Total { get; internal set; }
73+
}
74+
public class SnapshotStats
75+
{
76+
[JsonProperty("number_of_files")]
77+
public long NumberOfFiles { get; internal set; }
78+
[JsonProperty("processed_files")]
79+
public long ProcessedFiles { get; internal set; }
80+
[JsonProperty("total_size_in_bytes")]
81+
public long TotalSizeInBytes { get; internal set; }
82+
[JsonProperty("processed_size_in_bytes")]
83+
public long ProcessedSizeInBytes { get; internal set; }
84+
[JsonProperty("start_time_in_millis")]
85+
public long StartTimeInMilliseconds { get; internal set; }
86+
[JsonProperty("time_in_millis")]
87+
public long TimeInMilliseconds { get; internal set; }
88+
}
89+
}

src/Nest/ElasticClient-Snapshot.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,42 @@ public Task<IGetSnapshotResponse> GetSnapshotAsync(IGetSnapshotRequest getSnapsh
9595
}
9696

9797

98+
/// <inheritdoc />
99+
public ISnapshotStatusResponse SnapshotStatus(Func<SnapshotStatusDescriptor, SnapshotStatusDescriptor> selector = null)
100+
{
101+
return this.Dispatch<SnapshotStatusDescriptor, SnapshotStatusRequestParameters, SnapshotStatusResponse>(
102+
selector,
103+
(p, d) => this.RawDispatch.SnapshotStatusDispatch<SnapshotStatusResponse>(p)
104+
);
105+
}
106+
107+
/// <inheritdoc />
108+
public ISnapshotStatusResponse SnapshotStatus(ISnapshotStatusRequest getSnapshotRequest)
109+
{
110+
return this.Dispatch<ISnapshotStatusRequest, SnapshotStatusRequestParameters, SnapshotStatusResponse>(
111+
getSnapshotRequest,
112+
(p, d) => this.RawDispatch.SnapshotStatusDispatch<SnapshotStatusResponse>(p)
113+
);
114+
}
115+
116+
/// <inheritdoc />
117+
public Task<ISnapshotStatusResponse> SnapshotStatusAsync(Func<SnapshotStatusDescriptor, SnapshotStatusDescriptor> selector = null)
118+
{
119+
return this.DispatchAsync<SnapshotStatusDescriptor, SnapshotStatusRequestParameters, SnapshotStatusResponse, ISnapshotStatusResponse>(
120+
selector,
121+
(p, d) => this.RawDispatch.SnapshotStatusDispatchAsync<SnapshotStatusResponse>(p)
122+
);
123+
}
124+
125+
/// <inheritdoc />
126+
public Task<ISnapshotStatusResponse> SnapshotStatusAsync(ISnapshotStatusRequest getSnapshotRequest)
127+
{
128+
return this.DispatchAsync<ISnapshotStatusRequest, SnapshotStatusRequestParameters, SnapshotStatusResponse, ISnapshotStatusResponse>(
129+
getSnapshotRequest,
130+
(p, d) => this.RawDispatch.SnapshotStatusDispatchAsync<SnapshotStatusResponse>(p)
131+
);
132+
}
133+
98134

99135

100136
/// <inheritdoc />

src/Nest/IElasticClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,17 @@ Task<IGetFieldMappingResponse> GetFieldMappingAsync<T>(Func<GetFieldMappingDescr
13811381
Task<IPingResponse> PingAsync(IPingRequest pingRequest);
13821382

13831383
/// <inheritdoc />
1384+
ISnapshotStatusResponse SnapshotStatus(Func<SnapshotStatusDescriptor, SnapshotStatusDescriptor> selector = null);
1385+
1386+
/// <inheritdoc />
1387+
ISnapshotStatusResponse SnapshotStatus(ISnapshotStatusRequest getSnapshotRequest);
1388+
1389+
/// <inheritdoc />
1390+
Task<ISnapshotStatusResponse> SnapshotStatusAsync(Func<SnapshotStatusDescriptor, SnapshotStatusDescriptor> selector = null);
1391+
1392+
/// <inheritdoc />
1393+
Task<ISnapshotStatusResponse> SnapshotStatusAsync(ISnapshotStatusRequest getSnapshotRequest);
1394+
13841395
IRecoveryStatusResponse RecoveryStatus(Func<RecoveryStatusDescriptor, RecoveryStatusDescriptor> selector = null);
13851396

13861397
/// <inheritdoc />

src/Nest/Nest.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<Compile Include="Domain\Responses\ExplainResponse.cs" />
183183
<Compile Include="Domain\Responses\GetFieldMappingResponse.cs" />
184184
<Compile Include="Domain\Cat\ICatRecord.cs" />
185+
<Compile Include="Domain\Responses\SnapshotStatusResponse.cs" />
185186
<Compile Include="Domain\Responses\MultiPercolateResponse.cs" />
186187
<Compile Include="Domain\Responses\NodesHotThreadsResponse.cs" />
187188
<Compile Include="Domain\Responses\CatResponse.cs" />
@@ -219,6 +220,8 @@
219220
<Compile Include="DSL\ClusterPendingTasksDescriptor.cs" />
220221
<Compile Include="DSL\ClusterStatsDescriptor.cs" />
221222
<Compile Include="DSL\CatAliasesDescriptor.cs" />
223+
<Compile Include="DSL\Paths\RepositorySnapshotOptionalPathDescriptor.cs" />
224+
<Compile Include="DSL\SnapshotStatusDescriptor.cs" />
222225
<Compile Include="DSL\RecoveryStatusDescriptor.cs" />
223226
<Compile Include="DSL\TemplateExistsDescriptor.cs" />
224227
<Compile Include="Domain\Responses\PingResponse.cs" />

0 commit comments

Comments
 (0)