Skip to content

Commit e2c990f

Browse files
Mpdreamzgmarz
authored andcommitted
Implemented missing cat endpoints
* cat snapshots * cat nodeattrs * cat help * cat repositories Should backport this to 2.x
1 parent 5540dd7 commit e2c990f

33 files changed

+836
-698
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/cat.snapshots.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"parts": {
99
"repository": {
1010
"type" : "list",
11+
"required" : true,
1112
"description": "Name of repository from which to fetch the snapshot information"
1213
}
1314
},

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/root.html

Lines changed: 161 additions & 648 deletions
Large diffs are not rendered by default.

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static ApiGenerator()
5151
}
5252
else
5353
{
54-
NestFolder = @"..\..\..\..\..\src\Nest\";
55-
EsNetFolder = @"..\..\..\..\..\src\Elasticsearch.Net\";
56-
ViewFolder = @"..\..\Views\";
57-
ApiEndpointsFolder = @"..\..\ApiEndpoints\";
54+
NestFolder = @"..\..\..\..\..\..\src\Nest\";
55+
EsNetFolder = @"..\..\..\..\..\..\src\Elasticsearch.Net\";
56+
ViewFolder = @"..\..\..\Views\";
57+
ApiEndpointsFolder = @"..\..\..\ApiEndpoints\";
5858
}
5959
}
6060

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiEndpoint.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
123123

124124
}
125125
});
126+
126127
//.NET does not allow get requests to have a body payload.
127128
if (method != "GET" && this.Body != null)
128129
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Nest
4+
{
5+
[JsonObject]
6+
public class CatHelpRecord : ICatRecord
7+
{
8+
[JsonProperty("endpoint")]
9+
public string Endpoint { get; set; }
10+
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Nest
2+
{
3+
public partial interface ICatHelpRequest { }
4+
5+
public partial class CatHelpRequest { }
6+
7+
public partial class CatHelpDescriptor { }
8+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Elasticsearch.Net;
8+
9+
namespace Nest
10+
{
11+
public partial interface IElasticClient
12+
{
13+
/// <inheritdoc/>
14+
ICatResponse<CatHelpRecord> CatHelp(Func<CatHelpDescriptor, ICatHelpRequest> selector = null);
15+
16+
/// <inheritdoc/>
17+
ICatResponse<CatHelpRecord> CatHelp(ICatHelpRequest request);
18+
19+
/// <inheritdoc/>
20+
Task<ICatResponse<CatHelpRecord>> CatHelpAsync(Func<CatHelpDescriptor, ICatHelpRequest> selector = null);
21+
22+
/// <inheritdoc/>
23+
Task<ICatResponse<CatHelpRecord>> CatHelpAsync(ICatHelpRequest request);
24+
25+
}
26+
27+
public partial class ElasticClient
28+
{
29+
30+
private CatResponse<CatHelpRecord> DeserializeCatHelpResponse(IApiCallDetails response, Stream stream)
31+
{
32+
using (stream)
33+
using (var ms = new MemoryStream())
34+
{
35+
stream.CopyTo(ms);
36+
var body = Encoding.UTF8.GetString(ms.ToArray());
37+
return new CatResponse<CatHelpRecord>
38+
{
39+
Records = body.Split('\n').Skip(1)
40+
.Select(f => new CatHelpRecord { Endpoint = f.Trim() })
41+
.ToList()
42+
};
43+
}
44+
}
45+
46+
/// <inheritdoc/>
47+
public ICatResponse<CatHelpRecord> CatHelp(Func<CatHelpDescriptor, ICatHelpRequest> selector = null) =>
48+
this.CatHelp(selector.InvokeOrDefault(new CatHelpDescriptor()));
49+
50+
/// <inheritdoc/>
51+
public ICatResponse<CatHelpRecord> CatHelp(ICatHelpRequest request) =>
52+
this.Dispatcher.Dispatch<ICatHelpRequest, CatHelpRequestParameters, CatResponse<CatHelpRecord>>(
53+
request,
54+
new Func<IApiCallDetails, Stream, CatResponse<CatHelpRecord>>(this.DeserializeCatHelpResponse),
55+
(p, d) => this.LowLevelDispatch.CatHelpDispatch<CatResponse<CatHelpRecord>>(p)
56+
);
57+
58+
/// <inheritdoc/>
59+
public Task<ICatResponse<CatHelpRecord>> CatHelpAsync(Func<CatHelpDescriptor, ICatHelpRequest> selector = null) =>
60+
this.CatHelpAsync(selector.InvokeOrDefault(new CatHelpDescriptor()));
61+
62+
/// <inheritdoc/>
63+
public Task<ICatResponse<CatHelpRecord>> CatHelpAsync(ICatHelpRequest request) =>
64+
this.Dispatcher.DispatchAsync<ICatHelpRequest, CatHelpRequestParameters, CatResponse<CatHelpRecord>, ICatResponse<CatHelpRecord>>(
65+
request,
66+
new Func<IApiCallDetails, Stream, CatResponse<CatHelpRecord>>(this.DeserializeCatHelpResponse),
67+
(p, d) => this.LowLevelDispatch.CatHelpDispatchAsync<CatResponse<CatHelpRecord>>(p)
68+
);
69+
70+
}
71+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Nest
4+
{
5+
[JsonObject]
6+
public class CatNodeAttributesRecord : ICatRecord
7+
{
8+
// duration indices successful_shards failed_shards total_shards
9+
[JsonProperty("id")]
10+
public string Id { get; set; }
11+
12+
[JsonProperty("node")]
13+
public string Node { get; set; }
14+
15+
[JsonProperty("pid")]
16+
public long ProcessId { get; set; }
17+
18+
[JsonProperty("host")]
19+
public string Host { get; set; }
20+
21+
[JsonProperty("ip")]
22+
public string Ip { get; set; }
23+
24+
[JsonProperty("port")]
25+
public long Port { get; set; }
26+
27+
[JsonProperty("attr")]
28+
public string Attribute { get; set; }
29+
30+
[JsonProperty("value")]
31+
public string Value { get; set; }
32+
33+
}
34+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
#pragma warning disable 612
3+
4+
namespace Nest
5+
{
6+
[Obsolete()]
7+
public partial interface ICatNodeattrsRequest { }
8+
9+
[Obsolete()]
10+
public partial class CatNodeattrsRequest { }
11+
12+
[Obsolete()]
13+
public partial class CatNodeattrsDescriptor { }
14+
15+
16+
public interface ICatNodeAttributesRequest : ICatNodeattrsRequest { }
17+
public class CatNodeAttributesRequest : CatNodeattrsRequest, ICatNodeAttributesRequest { }
18+
public class CatNodeAttributesDescriptor : CatNodeattrsDescriptor, ICatNodeAttributesRequest { }
19+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Elasticsearch.Net;
4+
5+
namespace Nest
6+
{
7+
public partial interface IElasticClient
8+
{
9+
/// <inheritdoc/>
10+
ICatResponse<CatNodeAttributesRecord> CatNodeAttributes(Func<CatNodeAttributesDescriptor, ICatNodeAttributesRequest> selector = null);
11+
12+
/// <inheritdoc/>
13+
ICatResponse<CatNodeAttributesRecord> CatNodeAttributes(ICatNodeAttributesRequest request);
14+
15+
/// <inheritdoc/>
16+
Task<ICatResponse<CatNodeAttributesRecord>> CatNodeAttributesAsync(Func<CatNodeAttributesDescriptor, ICatNodeAttributesRequest> selector = null);
17+
18+
/// <inheritdoc/>
19+
Task<ICatResponse<CatNodeAttributesRecord>> CatNodeAttributesAsync(ICatNodeAttributesRequest request);
20+
21+
}
22+
23+
public partial class ElasticClient
24+
{
25+
/// <inheritdoc/>
26+
public ICatResponse<CatNodeAttributesRecord> CatNodeAttributes(Func<CatNodeAttributesDescriptor, ICatNodeAttributesRequest> selector = null) =>
27+
this.CatNodeAttributes(selector.InvokeOrDefault(new CatNodeAttributesDescriptor()));
28+
29+
/// <inheritdoc/>
30+
public ICatResponse<CatNodeAttributesRecord> CatNodeAttributes(ICatNodeAttributesRequest request) =>
31+
this.DoCat<ICatNodeAttributesRequest, CatNodeattrsRequestParameters, CatNodeAttributesRecord>(request, this.LowLevelDispatch.CatNodeattrsDispatch<CatResponse<CatNodeAttributesRecord>>);
32+
33+
/// <inheritdoc/>
34+
public Task<ICatResponse<CatNodeAttributesRecord>> CatNodeAttributesAsync(Func<CatNodeAttributesDescriptor, ICatNodeAttributesRequest> selector = null) =>
35+
this.CatNodeAttributesAsync(selector.InvokeOrDefault(new CatNodeAttributesDescriptor()));
36+
37+
/// <inheritdoc/>
38+
public Task<ICatResponse<CatNodeAttributesRecord>> CatNodeAttributesAsync(ICatNodeAttributesRequest request) =>
39+
this.DoCatAsync<ICatNodeAttributesRequest, CatNodeattrsRequestParameters, CatNodeAttributesRecord>(request, this.LowLevelDispatch.CatNodeattrsDispatchAsync<CatResponse<CatNodeAttributesRecord>>);
40+
41+
}
42+
}

0 commit comments

Comments
 (0)