1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
4+ using System . Threading . Tasks ;
5+ using Elasticsearch . Net ;
6+
7+ namespace Nest
8+ {
9+ public partial class ElasticClient
10+ {
11+
12+ /// <inheritdoc />
13+ public ICatResponse < CatAliasesRecord > CatAliases ( Func < CatAliasesDescriptor , CatAliasesDescriptor > selector = null )
14+ {
15+ return this . DoCat < CatAliasesDescriptor , CatAliasesRequestParameters , CatAliasesRecord > ( selector , this . RawDispatch . CatAliasesDispatch < CatResponse < CatAliasesRecord > > ) ;
16+ }
17+
18+ public ICatResponse < CatAliasesRecord > CatAliases ( ICatAliasesRequest request )
19+ {
20+ return this . DoCat < ICatAliasesRequest , CatAliasesRequestParameters , CatAliasesRecord > ( request , this . RawDispatch . CatAliasesDispatch < CatResponse < CatAliasesRecord > > ) ;
21+ }
22+
23+ public Task < ICatResponse < CatAliasesRecord > > CatAliasesAsync ( Func < CatAliasesDescriptor , CatAliasesDescriptor > selector = null )
24+ {
25+ return this . DoCatAsync < CatAliasesDescriptor , CatAliasesRequestParameters , CatAliasesRecord > ( selector , this . RawDispatch . CatAliasesDispatchAsync < CatResponse < CatAliasesRecord > > ) ;
26+ }
27+
28+ public Task < ICatResponse < CatAliasesRecord > > CatAliasesAsync ( ICatAliasesRequest request )
29+ {
30+ return this . DoCatAsync < ICatAliasesRequest , CatAliasesRequestParameters , CatAliasesRecord > ( request , this . RawDispatch . CatAliasesDispatchAsync < CatResponse < CatAliasesRecord > > ) ;
31+ }
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+ private CatResponse < TCatRecord > DeserializeCatResponse < TCatRecord > ( IElasticsearchResponse response , Stream stream )
42+ where TCatRecord : ICatRecord
43+ {
44+ var records = this . Serializer . Deserialize < IEnumerable < TCatRecord > > ( stream ) ;
45+ return new CatResponse < TCatRecord > ( response ) { Records = records } ;
46+ }
47+
48+
49+ private Task < ICatResponse < TCatRecord > > DoCatAsync < TRequest , TParams , TCatRecord > (
50+ Func < TRequest , TRequest > selector ,
51+ Func < ElasticsearchPathInfo < TParams > , Task < ElasticsearchResponse < CatResponse < TCatRecord > > > > dispatch
52+ )
53+ where TCatRecord : ICatRecord
54+ where TParams : FluentRequestParameters < TParams > , new ( )
55+ where TRequest : class , IRequest < TParams > , new ( )
56+ {
57+ return this . DispatchAsync < TRequest , TParams , CatResponse < TCatRecord > , ICatResponse < TCatRecord > > (
58+ this . ForceConfiguration ( selector , c => c . ContentType = "application/json" ) ,
59+ ( p , d ) => dispatch ( p . DeserializationState (
60+ new Func < IElasticsearchResponse , Stream , CatResponse < TCatRecord > > ( this . DeserializeCatResponse < TCatRecord > ) )
61+ )
62+ ) ;
63+ }
64+
65+ private Task < ICatResponse < TCatRecord > > DoCatAsync < TRequest , TParams , TCatRecord > (
66+ TRequest request ,
67+ Func < ElasticsearchPathInfo < TParams > , Task < ElasticsearchResponse < CatResponse < TCatRecord > > > > dispatch
68+ )
69+ where TCatRecord : ICatRecord
70+ where TParams : FluentRequestParameters < TParams > , new ( )
71+ where TRequest : IRequest < TParams >
72+ {
73+ return this . DispatchAsync < TRequest , TParams , CatResponse < TCatRecord > , ICatResponse < TCatRecord > > (
74+ this . ForceConfiguration ( request , c => c . ContentType = "application/json" ) ,
75+ ( p , d ) => dispatch ( p . DeserializationState (
76+ new Func < IElasticsearchResponse , Stream , CatResponse < TCatRecord > > ( this . DeserializeCatResponse < TCatRecord > ) )
77+ )
78+ ) ;
79+ }
80+
81+ private ICatResponse < TCatRecord > DoCat < TRequest , TParams , TCatRecord > (
82+ Func < TRequest , TRequest > selector ,
83+ Func < ElasticsearchPathInfo < TParams > , ElasticsearchResponse < CatResponse < TCatRecord > > > dispatch
84+ )
85+ where TCatRecord : ICatRecord
86+ where TParams : FluentRequestParameters < TParams > , new ( )
87+ where TRequest : class , IRequest < TParams > , new ( )
88+ {
89+ return this . Dispatch < TRequest , TParams , CatResponse < TCatRecord > > (
90+ this . ForceConfiguration ( selector , c => c . ContentType = "application/json" ) ,
91+ ( p , d ) => dispatch ( p . DeserializationState (
92+ new Func < IElasticsearchResponse , Stream , CatResponse < TCatRecord > > ( this . DeserializeCatResponse < TCatRecord > ) )
93+ )
94+ ) ;
95+ }
96+
97+ private ICatResponse < TCatRecord > DoCat < TRequest , TParams , TCatRecord > (
98+ TRequest request ,
99+ Func < ElasticsearchPathInfo < TParams > , ElasticsearchResponse < CatResponse < TCatRecord > > > dispatch
100+ )
101+ where TCatRecord : ICatRecord
102+ where TParams : FluentRequestParameters < TParams > , new ( )
103+ where TRequest : IRequest < TParams >
104+ {
105+ return this . Dispatch < TRequest , TParams , CatResponse < TCatRecord > > (
106+ this . ForceConfiguration ( request , c => c . ContentType = "application/json" ) ,
107+ ( p , d ) => dispatch ( p . DeserializationState (
108+ new Func < IElasticsearchResponse , Stream , CatResponse < TCatRecord > > ( this . DeserializeCatResponse < TCatRecord > ) )
109+ )
110+ ) ;
111+ }
112+ }
113+ }
0 commit comments