22// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information
44
5+ using System ;
56using System . Threading ;
67using System . Threading . Tasks ;
78using static Elastic . Transport . HttpMethod ;
@@ -37,6 +38,8 @@ public static Task<TResponse> GetAsync<TResponse>(this ITransport transport, str
3738 where TResponse : TransportResponse , new ( ) =>
3839 transport . RequestAsync < TResponse > ( new EndpointPath ( GET , pathAndQuery ) , postData : null , null , null , cancellationToken ) ;
3940
41+
42+
4043 /// <summary>Perform a HEAD request</summary>
4144 public static VoidResponse Head ( this ITransport < ITransportConfiguration > transport , string path , RequestParameters parameters )
4245 => transport . Request < VoidResponse > ( ToEndpointPath ( HEAD , path , parameters , transport . Configuration ) , postData : null , null , null ) ;
@@ -53,6 +56,16 @@ public static VoidResponse Head(this ITransport transport, string pathAndQuery)
5356 public static Task < VoidResponse > HeadAsync ( this ITransport transport , string pathAndQuery , CancellationToken cancellationToken = default )
5457 => transport . RequestAsync < VoidResponse > ( new EndpointPath ( HEAD , pathAndQuery ) , postData : null , null , null , cancellationToken ) ;
5558
59+ /// <summary>Perform a HEAD request</summary>
60+ public static VoidResponse Head ( this ITransport transport , string pathAndQuery , TimeSpan timeout )
61+ => transport . Request < VoidResponse > ( new EndpointPath ( HEAD , pathAndQuery ) , postData : null , null , new RequestConfiguration { RequestTimeout = timeout } ) ;
62+
63+ /// <summary>Perform a HEAD request</summary>
64+ public static Task < VoidResponse > HeadAsync ( this ITransport transport , string pathAndQuery , TimeSpan timeout , CancellationToken cancellationToken = default )
65+ => transport . RequestAsync < VoidResponse > ( new EndpointPath ( HEAD , pathAndQuery ) , postData : null , null , new RequestConfiguration { RequestTimeout = timeout } , cancellationToken ) ;
66+
67+
68+
5669 /// <summary>Perform a POST request</summary>
5770 public static TResponse Post < TResponse > ( this ITransport < ITransportConfiguration > transport , string path , PostData data , RequestParameters parameters )
5871 where TResponse : TransportResponse , new ( ) =>
@@ -74,6 +87,17 @@ public static Task<TResponse> PostAsync<TResponse>(this ITransport transport, st
7487 where TResponse : TransportResponse , new ( ) =>
7588 transport . RequestAsync < TResponse > ( new EndpointPath ( POST , pathAndQuery ) , data , null , null , cancellationToken ) ;
7689
90+ /// <summary>Perform a POST request</summary>
91+ public static TResponse Post < TResponse > ( this ITransport transport , string pathAndQuery , PostData data , TimeSpan timeout )
92+ where TResponse : TransportResponse , new ( ) =>
93+ transport . Request < TResponse > ( new EndpointPath ( POST , pathAndQuery ) , data , null , new RequestConfiguration { RequestTimeout = timeout } ) ;
94+
95+ /// <summary>Perform a POST request</summary>
96+ public static Task < TResponse > PostAsync < TResponse > ( this ITransport transport , string pathAndQuery , PostData data , TimeSpan timeout , CancellationToken cancellationToken = default )
97+ where TResponse : TransportResponse , new ( ) =>
98+ transport . RequestAsync < TResponse > ( new EndpointPath ( POST , pathAndQuery ) , data , null , new RequestConfiguration { RequestTimeout = timeout } , cancellationToken ) ;
99+
100+
77101 /// <summary>Perform a PUT request</summary>
78102 public static TResponse Put < TResponse > ( this ITransport < ITransportConfiguration > transport , string path , PostData data , RequestParameters parameters )
79103 where TResponse : TransportResponse , new ( ) =>
@@ -94,6 +118,17 @@ public static Task<TResponse> PutAsync<TResponse>(this ITransport transport, str
94118 where TResponse : TransportResponse , new ( ) =>
95119 transport . RequestAsync < TResponse > ( new EndpointPath ( PUT , pathAndQuery ) , data , null , null , cancellationToken ) ;
96120
121+ /// <summary>Perform a PUT request</summary>
122+ public static TResponse Put < TResponse > ( this ITransport transport , string pathAndQuery , PostData data , TimeSpan timeout )
123+ where TResponse : TransportResponse , new ( ) =>
124+ transport . Request < TResponse > ( new EndpointPath ( PUT , pathAndQuery ) , data , null , new RequestConfiguration { RequestTimeout = timeout } ) ;
125+
126+ /// <summary>Perform a PUT request</summary>
127+ public static Task < TResponse > PutAsync < TResponse > ( this ITransport transport , string pathAndQuery , PostData data , TimeSpan timeout , CancellationToken cancellationToken = default )
128+ where TResponse : TransportResponse , new ( ) =>
129+ transport . RequestAsync < TResponse > ( new EndpointPath ( PUT , pathAndQuery ) , data , null , new RequestConfiguration { RequestTimeout = timeout } , cancellationToken ) ;
130+
131+
97132 /// <summary>Perform a DELETE request</summary>
98133 public static TResponse Delete < TResponse > ( this ITransport < ITransportConfiguration > transport , string path , RequestParameters parameters , PostData ? data = null )
99134 where TResponse : TransportResponse , new ( ) =>
@@ -105,12 +140,13 @@ public static Task<TResponse> DeleteAsync<TResponse>(this ITransport<ITransportC
105140 transport . RequestAsync < TResponse > ( ToEndpointPath ( DELETE , path , parameters , transport . Configuration ) , data , null , null , cancellationToken ) ;
106141
107142 /// <summary>Perform a DELETE request</summary>
108- public static TResponse Delete < TResponse > ( this ITransport transport , string pathAndQuery , PostData ? data = null )
143+ public static TResponse Delete < TResponse > ( this ITransport transport , string pathAndQuery , PostData ? data = null , TimeSpan ? timeout = null )
109144 where TResponse : TransportResponse , new ( ) =>
110- transport . Request < TResponse > ( new EndpointPath ( DELETE , pathAndQuery ) , data , null , null ) ;
145+ transport . Request < TResponse > ( new EndpointPath ( DELETE , pathAndQuery ) , data , null , timeout == null ? null : new RequestConfiguration { RequestTimeout = timeout } ) ;
111146
112147 /// <summary>Perform a DELETE request</summary>
113- public static Task < TResponse > DeleteAsync < TResponse > ( this ITransport transport , string pathAndQuery , PostData ? data = null , CancellationToken cancellationToken = default )
148+ public static Task < TResponse > DeleteAsync < TResponse > ( this ITransport transport , string pathAndQuery , PostData ? data = null , TimeSpan ? timeout = null , CancellationToken cancellationToken = default )
114149 where TResponse : TransportResponse , new ( ) =>
115- transport . RequestAsync < TResponse > ( new EndpointPath ( DELETE , pathAndQuery ) , data , null , null , cancellationToken ) ;
150+ transport . RequestAsync < TResponse > ( new EndpointPath ( DELETE , pathAndQuery ) , data , null , timeout == null ? null : new RequestConfiguration { RequestTimeout = timeout } , cancellationToken ) ;
151+
116152}
0 commit comments