Skip to content

Commit 4fcecae

Browse files
committed
Revert "removed Wrap() from low level client and ElasticsearchResponse, removed unecessary clonefroms in NEST but could not delete the ones in the low level client, used to short circuit auth failures or void responses"
This reverts commit c5e8510. Conflicts: src/Elasticsearch.Net/Domain/Response/ElasticsearchResponse.cs
1 parent e22f560 commit 4fcecae

File tree

10 files changed

+1049
-1075
lines changed

10 files changed

+1049
-1075
lines changed

Diff for: src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiEndpoint.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
213213
QueryStringParamName = queryStringParamName,
214214
ReturnType = string.Format("ElasticsearchResponse<{0}>", defaultBoundGeneric),
215215
ReturnTypeGeneric = null,
216-
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
217-
CallTypeGeneric = defaultBoundGeneric,
216+
CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary"
217+
? "Dictionary<string, object>" : defaultBoundGeneric,
218218
ReturnDescription =
219219
"ElasticsearchResponse&lt;T&gt; holding the response body deserialized as DynamicDictionary"
220220
+ explanationOfDynamic,
@@ -234,8 +234,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
234234
QueryStringParamName = queryStringParamName,
235235
ReturnType = string.Format("Task<ElasticsearchResponse<{0}>>", defaultBoundGeneric),
236236
ReturnTypeGeneric = null,
237-
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
238-
CallTypeGeneric = defaultBoundGeneric,
237+
CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary"
238+
? "Dictionary<string, object>" : defaultBoundGeneric,
239239
ReturnDescription =
240240
"Task that'll return an ElasticsearchResponse&lt;T$gt; holding the response body deserialized as DynamicDictionary"
241241
+ explanationOfDynamic,

Diff for: src/Elasticsearch.Net/Domain/Response/ElasticsearchResponse.cs

+25-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,26 @@ namespace Elasticsearch.Net
2222
// TODO: Make this class internal in 2.0
2323
public static class ElasticsearchResponse
2424
{
25-
internal static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse from, TTo to)
25+
public static Task<ElasticsearchResponse<DynamicDictionary>> WrapAsync(Task<ElasticsearchResponse<Dictionary<string, object>>> responseTask)
26+
{
27+
return responseTask
28+
.ContinueWith(t =>
29+
{
30+
if (t.IsFaulted && t.Exception != null)
31+
{
32+
t.Exception.Flatten().InnerException.RethrowKeepingStackTrace();
33+
return null; //won't be hit
34+
}
35+
return ToDynamicResponse(t.Result);
36+
});
37+
}
38+
39+
public static ElasticsearchResponse<DynamicDictionary> Wrap(ElasticsearchResponse<Dictionary<string, object>> response)
40+
{
41+
return ToDynamicResponse(response);
42+
}
43+
44+
public static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse from, TTo to)
2645
{
2746
var response = new ElasticsearchResponse<TTo>(from.Settings)
2847
{
@@ -43,6 +62,11 @@ internal static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse
4362
tt.RequestInformation = response;
4463
return response;
4564
}
65+
66+
public static ElasticsearchResponse<DynamicDictionary> ToDynamicResponse(ElasticsearchResponse<Dictionary<string, object>> response)
67+
{
68+
return CloneFrom(response, response.Response != null ? DynamicDictionary.Create(response.Response) : null);
69+
}
4670
}
4771

4872
public class ElasticsearchResponse<T> : IElasticsearchResponse

0 commit comments

Comments
 (0)