@@ -37,6 +37,8 @@ public interface IArgoClient
37
37
Task < Version ? > Argo_GetVersionAsync ( ) ;
38
38
39
39
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 ) ;
40
42
}
41
43
42
44
public class ArgoClient : IArgoClient
@@ -62,7 +64,7 @@ public async Task<Workflow> Argo_CreateWorkflowAsync(string argoNamespace, Workf
62
64
63
65
var Method = "POST" ;
64
66
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 ) ;
66
68
67
69
}
68
70
@@ -99,7 +101,7 @@ public async Task<Workflow> Argo_StopWorkflowAsync(string argoNamespace, string
99
101
100
102
var Method = "PUT" ;
101
103
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 ) ;
103
105
104
106
}
105
107
@@ -114,7 +116,7 @@ public async Task<Workflow> Argo_TerminateWorkflowAsync(string argoNamespace, st
114
116
115
117
var Method = "PUT" ;
116
118
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 ) ;
118
120
}
119
121
120
122
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
162
164
urlBuilder . Length -- ;
163
165
return await GetRequest < string > ( urlBuilder , true ) . ConfigureAwait ( false ) ;
164
166
}
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 )
166
168
{
167
169
using ( var request = new HttpRequestMessage ( ) )
168
170
{
@@ -172,7 +174,17 @@ private async Task<Workflow> SendRequest(StringContent stringContent, StringBuil
172
174
request . Headers . Accept . Add ( System . Net . Http . Headers . MediaTypeWithQualityHeaderValue . Parse ( "application/json" ) ) ;
173
175
request . RequestUri = new Uri ( urlBuilder . ToString ( ) , UriKind . RelativeOrAbsolute ) ;
174
176
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
+
176
188
177
189
try
178
190
{
@@ -186,7 +198,7 @@ private async Task<Workflow> SendRequest(StringContent stringContent, StringBuil
186
198
var status = ( int ) response . StatusCode ;
187
199
if ( status == 200 )
188
200
{
189
- var objectResponse_ = await ReadObjectResponseAsync < Workflow > ( response , headers ) . ConfigureAwait ( false ) ;
201
+ var objectResponse_ = await ReadObjectResponseAsync < T > ( response , headers ) . ConfigureAwait ( false ) ;
190
202
if ( objectResponse_ . Object == null )
191
203
{
192
204
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(
336
348
}
337
349
}
338
350
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
+
339
367
protected struct ObjectResponseResult < T >
340
368
{
341
369
public ObjectResponseResult ( T responseObject , string responseText )
0 commit comments