Skip to content

Commit 9b12ea6

Browse files
committed
Fix #934 Exposed DoRequest on NEST and Elasticsearch.NET clients
1 parent b83ac02 commit 9b12ea6

File tree

6 files changed

+106
-6
lines changed

6 files changed

+106
-6
lines changed

src/Elasticsearch.Net/ElasticsearchClient.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,31 @@ public string Encoded(object o)
5050
return Uri.EscapeDataString(this.Serializer.Stringify(o));
5151
}
5252

53-
54-
protected ElasticsearchResponse<T> DoRequest<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
53+
54+
/// <summary>
55+
/// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover.
56+
/// </summary>
57+
/// <typeparam name="T">The type representing the response JSON</typeparam>
58+
/// <param name="method">the HTTP Method to use</param>
59+
/// <param name="path">The path of the the url that you would like to hit</param>
60+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
61+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
62+
/// <returns>An ElasticsearchResponse of T where T represents the JSON response body</returns>
63+
public ElasticsearchResponse<T> DoRequest<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
5564
{
5665
return this.Transport.DoRequest<T>(method, path, data, requestParameters);
5766
}
5867

59-
60-
protected Task<ElasticsearchResponse<T>> DoRequestAsync<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
68+
/// <summary>
69+
/// Perform any request you want over the configured IConnection asynchronously while taking advantage of the cluster failover.
70+
/// </summary>
71+
/// <typeparam name="T">The type representing the response JSON</typeparam>
72+
/// <param name="method">the HTTP Method to use</param>
73+
/// <param name="path">The path of the the url that you would like to hit</param>
74+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
75+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
76+
/// <returns>A task of ElasticsearchResponse of T where T represents the JSON response body</returns>
77+
public Task<ElasticsearchResponse<T>> DoRequestAsync<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
6178
{
6279
return this.Transport.DoRequestAsync<T>(method, path, data, requestParameters);
6380
}

src/Elasticsearch.Net/IElasticsearchClient.Generated.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19439,6 +19439,27 @@ public interface IElasticsearchClient
1943919439
///</returns>
1944019440

1944119441
Task<ElasticsearchResponse<DynamicDictionary>> UpdateAsync(string index, string type, string id, object body, Func<UpdateRequestParameters, UpdateRequestParameters> requestParameters = null);
19442-
19442+
19443+
/// <summary>
19444+
/// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover.
19445+
/// </summary>
19446+
/// <typeparam name="T">The type representing the response JSON</typeparam>
19447+
/// <param name="method">the HTTP Method to use</param>
19448+
/// <param name="path">The path of the the url that you would like to hit</param>
19449+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
19450+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
19451+
/// <returns>An ElasticsearchResponse of T where T represents the JSON response body</returns>
19452+
ElasticsearchResponse<T> DoRequest<T>(string method, string path, object data = null, IRequestParameters requestParameters = null);
19453+
19454+
/// <summary>
19455+
/// Perform any request you want over the configured IConnection asynchronously while taking advantage of the cluster failover.
19456+
/// </summary>
19457+
/// <typeparam name="T">The type representing the response JSON</typeparam>
19458+
/// <param name="method">the HTTP Method to use</param>
19459+
/// <param name="path">The path of the the url that you would like to hit</param>
19460+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
19461+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
19462+
/// <returns>A task of ElasticsearchResponse of T where T represents the JSON response body</returns>
19463+
Task<ElasticsearchResponse<T>> DoRequestAsync<T>(string method, string path, object data = null, IRequestParameters requestParameters = null);
1944319464
}
1944419465
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using Elasticsearch.Net;
5+
6+
namespace Nest
7+
{
8+
public partial class ElasticClient
9+
{
10+
/// <summary>
11+
/// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover.
12+
/// </summary>
13+
/// <typeparam name="T">The type representing the response JSON</typeparam>
14+
/// <param name="method">the HTTP Method to use</param>
15+
/// <param name="path">The path of the the url that you would like to hit</param>
16+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
17+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
18+
/// <returns>An ElasticsearchResponse of T where T represents the JSON response body</returns>
19+
public ElasticsearchResponse<T> DoRequest<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
20+
{
21+
return this.Raw.DoRequest<T>(method, path, data, requestParameters);
22+
}
23+
24+
/// <summary>
25+
/// Perform any request you want over the configured IConnection asynchronously while taking advantage of the cluster failover.
26+
/// </summary>
27+
/// <typeparam name="T">The type representing the response JSON</typeparam>
28+
/// <param name="method">the HTTP Method to use</param>
29+
/// <param name="path">The path of the the url that you would like to hit</param>
30+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
31+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
32+
/// <returns>A task of ElasticsearchResponse of T where T represents the JSON response body</returns>
33+
public Task<ElasticsearchResponse<T>> DoRequestAsync<T>(string method, string path, object data = null, IRequestParameters requestParameters = null)
34+
{
35+
return this.Raw.DoRequestAsync<T>(method, path, data, requestParameters);
36+
}
37+
38+
}
39+
}

src/Nest/ElasticClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private static R CreateInvalidInstance<R>(IElasticsearchResponse response) where
111111
return r;
112112
}
113113

114-
internal Task<I> DispatchAsync<D, Q, R, I>(
114+
private Task<I> DispatchAsync<D, Q, R, I>(
115115
Func<D, D> selector
116116
, Func<ElasticsearchPathInfo<Q>, D, Task<ElasticsearchResponse<R>>> dispatch
117117
)

src/Nest/IElasticClient.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,5 +1455,27 @@ Task<ISearchShardsResponse> SearchShardsAsync<T>(Func<SearchShardsDescriptor<T>,
14551455

14561456
/// <inheritdoc />
14571457
Task<IRecoveryStatusResponse> RecoveryStatusAsync(IRecoveryStatusRequest statusRequest);
1458+
1459+
/// <summary>
1460+
/// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover.
1461+
/// </summary>
1462+
/// <typeparam name="T">The type representing the response JSON</typeparam>
1463+
/// <param name="method">the HTTP Method to use</param>
1464+
/// <param name="path">The path of the the url that you would like to hit</param>
1465+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
1466+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
1467+
/// <returns>An ElasticsearchResponse of T where T represents the JSON response body</returns>
1468+
ElasticsearchResponse<T> DoRequest<T>(string method, string path, object data = null, IRequestParameters requestParameters = null);
1469+
1470+
/// <summary>
1471+
/// Perform any request you want over the configured IConnection asynchronously while taking advantage of the cluster failover.
1472+
/// </summary>
1473+
/// <typeparam name="T">The type representing the response JSON</typeparam>
1474+
/// <param name="method">the HTTP Method to use</param>
1475+
/// <param name="path">The path of the the url that you would like to hit</param>
1476+
/// <param name="data">The body of the request, string and byte[] are posted as is other types will be serialized to JSON</param>
1477+
/// <param name="requestParameters">Optionally configure request specific timeouts, headers</param>
1478+
/// <returns>A task of ElasticsearchResponse of T where T represents the JSON response body</returns>
1479+
Task<ElasticsearchResponse<T>> DoRequestAsync<T>(string method, string path, object data = null, IRequestParameters requestParameters = null);
14581480
}
14591481
}

src/Nest/Nest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
<Compile Include="DSL\Visitor\VisitorScope.cs" />
327327
<Compile Include="DSL\_Requests.generated.cs" />
328328
<Compile Include="ElasticClient-Cat.cs" />
329+
<Compile Include="ElasticClient-DoRequest.cs" />
329330
<Compile Include="ElasticClient-SearchShards.cs" />
330331
<Compile Include="ElasticClient-RecoveryStatus.cs" />
331332
<Compile Include="ElasticClient-TemplateExists.cs" />

0 commit comments

Comments
 (0)