@@ -37,6 +37,8 @@ public interface IArgoClient
3737 Task < Version ? > Argo_GetVersionAsync ( ) ;
3838
3939 Task < string ? > Argo_Get_WorkflowLogsAsync ( string argoNamespace , string name , string podName , string logOptions_container ) ;
40+
41+ Task < WorkflowTemplate > Argo_CreateWorkflowTemplateAsync ( string argoNamespace , WorkflowTemplateCreateRequest body , CancellationToken cancellationToken ) ;
4042 }
4143
4244 public class ArgoClient : IArgoClient
@@ -62,7 +64,7 @@ public async Task<Workflow> Argo_CreateWorkflowAsync(string argoNamespace, Workf
6264
6365 var Method = "POST" ;
6466 var content = new StringContent ( Newtonsoft . Json . JsonConvert . SerializeObject ( body ) ) ;
65- return await SendRequest ( content , urlBuilder , Method , cancellationToken ) . ConfigureAwait ( false ) ;
67+ return await SendRequest < Workflow > ( content , urlBuilder , Method , cancellationToken ) . ConfigureAwait ( false ) ;
6668
6769 }
6870
@@ -99,7 +101,7 @@ public async Task<Workflow> Argo_StopWorkflowAsync(string argoNamespace, string
99101
100102 var Method = "PUT" ;
101103 var content = new StringContent ( Newtonsoft . Json . JsonConvert . SerializeObject ( body ) ) ;
102- return await SendRequest ( content , urlBuilder , Method , new CancellationToken ( ) ) . ConfigureAwait ( false ) ;
104+ return await SendRequest < Workflow > ( content , urlBuilder , Method , new CancellationToken ( ) ) . ConfigureAwait ( false ) ;
103105
104106 }
105107
@@ -114,7 +116,7 @@ public async Task<Workflow> Argo_TerminateWorkflowAsync(string argoNamespace, st
114116
115117 var Method = "PUT" ;
116118 var content = new StringContent ( Newtonsoft . Json . JsonConvert . SerializeObject ( body ) ) ;
117- return await SendRequest ( content , urlBuilder , Method , new CancellationToken ( ) ) . ConfigureAwait ( false ) ;
119+ return await SendRequest < Workflow > ( content , urlBuilder , Method , new CancellationToken ( ) ) . ConfigureAwait ( false ) ;
118120 }
119121
120122 public async Task < WorkflowTemplate > Argo_GetWorkflowTemplateAsync ( string argoNamespace , string name , string getOptions_resourceVersion )
@@ -162,7 +164,7 @@ public async Task<WorkflowTemplate> Argo_GetWorkflowTemplateAsync(string argoNam
162164 urlBuilder . Length -- ;
163165 return await GetRequest < string > ( urlBuilder , true ) . ConfigureAwait ( false ) ;
164166 }
165- private async Task < Workflow > SendRequest ( StringContent stringContent , StringBuilder urlBuilder , string Method , CancellationToken cancellationToken )
167+ private async Task < T > SendRequest < T > ( StringContent stringContent , StringBuilder urlBuilder , string Method , CancellationToken cancellationToken )
166168 {
167169 using ( var request = new HttpRequestMessage ( ) )
168170 {
@@ -172,7 +174,17 @@ private async Task<Workflow> SendRequest(StringContent stringContent, StringBuil
172174 request . Headers . Accept . Add ( System . Net . Http . Headers . MediaTypeWithQualityHeaderValue . Parse ( "application/json" ) ) ;
173175 request . RequestUri = new Uri ( urlBuilder . ToString ( ) , UriKind . RelativeOrAbsolute ) ;
174176
175- var response = await _httpClient . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead , cancellationToken ) . ConfigureAwait ( false ) ;
177+ HttpResponseMessage ? response = null ;
178+ try
179+ {
180+ response = await _httpClient . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead , cancellationToken ) . ConfigureAwait ( false ) ;
181+ }
182+ catch ( Exception ex )
183+ {
184+ var mess = ex . Message ;
185+ throw ;
186+ }
187+
176188
177189 try
178190 {
@@ -186,7 +198,7 @@ private async Task<Workflow> SendRequest(StringContent stringContent, StringBuil
186198 var status = ( int ) response . StatusCode ;
187199 if ( status == 200 )
188200 {
189- var objectResponse_ = await ReadObjectResponseAsync < Workflow > ( response , headers ) . ConfigureAwait ( false ) ;
201+ var objectResponse_ = await ReadObjectResponseAsync < T > ( response , headers ) . ConfigureAwait ( false ) ;
190202 if ( objectResponse_ . Object == null )
191203 {
192204 throw new ApiException ( "Response was null which was not expected." , status , objectResponse_ . Text , headers , null ) ;
@@ -336,6 +348,22 @@ protected virtual async Task<ObjectResponseResult<string>> ReadLogResponseAsync(
336348 }
337349 }
338350
351+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
352+ /// <returns>A successful response.</returns>
353+ /// <exception cref="ApiException">A server side error occurred.</exception>
354+ public virtual async Task < WorkflowTemplate > Argo_CreateWorkflowTemplateAsync ( string argoNamespace , WorkflowTemplateCreateRequest body , CancellationToken cancellationToken )
355+ {
356+ Guard . Against . NullOrWhiteSpace ( argoNamespace ) ;
357+ Guard . Against . Null ( body ) ;
358+
359+ var urlBuilder = new StringBuilder ( ) ;
360+ urlBuilder . Append ( CultureInfo . InvariantCulture , $ "{ FormattedBaseUrl } /api/v1/workflow-templates/{ argoNamespace } ") ;
361+
362+ var Method = "POST" ;
363+ var content = new StringContent ( Newtonsoft . Json . JsonConvert . SerializeObject ( body ) ) ;
364+ return await SendRequest < WorkflowTemplate > ( content , urlBuilder , Method , cancellationToken ) . ConfigureAwait ( false ) ;
365+ }
366+
339367 protected struct ObjectResponseResult < T >
340368 {
341369 public ObjectResponseResult ( T responseObject , string responseText )
0 commit comments