@@ -266,6 +266,219 @@ internal ManagedClustersOperations(ContainerServiceClient client)
266
266
return _result ;
267
267
}
268
268
269
+ /// <summary>
270
+ /// Gets a list of supported Kubernetes versions in the specified subscription.
271
+ /// </summary>
272
+ /// <remarks>
273
+ /// Contains extra metadata on the version, including supported patch versions,
274
+ /// capabilities, available upgrades, and details on preview status of the
275
+ /// version
276
+ /// </remarks>
277
+ /// <param name='location'>
278
+ /// The name of Azure region.
279
+ /// </param>
280
+ /// <param name='customHeaders'>
281
+ /// Headers that will be added to request.
282
+ /// </param>
283
+ /// <param name='cancellationToken'>
284
+ /// The cancellation token.
285
+ /// </param>
286
+ /// <exception cref="CloudException">
287
+ /// Thrown when the operation returned an invalid status code
288
+ /// </exception>
289
+ /// <exception cref="SerializationException">
290
+ /// Thrown when unable to deserialize the response
291
+ /// </exception>
292
+ /// <exception cref="ValidationException">
293
+ /// Thrown when a required parameter is null
294
+ /// </exception>
295
+ /// <exception cref="System.ArgumentNullException">
296
+ /// Thrown when a required parameter is null
297
+ /// </exception>
298
+ /// <return>
299
+ /// A response object containing the response body and response headers.
300
+ /// </return>
301
+ public async Task < AzureOperationResponse < KubernetesVersionListResult > > ListKubernetesVersionsWithHttpMessagesAsync ( string location , Dictionary < string , List < string > > customHeaders = null , CancellationToken cancellationToken = default ( CancellationToken ) )
302
+ {
303
+ if ( Client . ApiVersion == null )
304
+ {
305
+ throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
306
+ }
307
+ if ( Client . ApiVersion != null )
308
+ {
309
+ if ( Client . ApiVersion . Length < 1 )
310
+ {
311
+ throw new ValidationException ( ValidationRules . MinLength , "Client.ApiVersion" , 1 ) ;
312
+ }
313
+ }
314
+ if ( Client . SubscriptionId == null )
315
+ {
316
+ throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
317
+ }
318
+ if ( Client . SubscriptionId != null )
319
+ {
320
+ if ( Client . SubscriptionId . Length < 1 )
321
+ {
322
+ throw new ValidationException ( ValidationRules . MinLength , "Client.SubscriptionId" , 1 ) ;
323
+ }
324
+ }
325
+ if ( location == null )
326
+ {
327
+ throw new ValidationException ( ValidationRules . CannotBeNull , "location" ) ;
328
+ }
329
+ if ( location != null )
330
+ {
331
+ if ( location . Length < 1 )
332
+ {
333
+ throw new ValidationException ( ValidationRules . MinLength , "location" , 1 ) ;
334
+ }
335
+ }
336
+ // Tracing
337
+ bool _shouldTrace = ServiceClientTracing . IsEnabled ;
338
+ string _invocationId = null ;
339
+ if ( _shouldTrace )
340
+ {
341
+ _invocationId = ServiceClientTracing . NextInvocationId . ToString ( ) ;
342
+ Dictionary < string , object > tracingParameters = new Dictionary < string , object > ( ) ;
343
+ tracingParameters . Add ( "location" , location ) ;
344
+ tracingParameters . Add ( "cancellationToken" , cancellationToken ) ;
345
+ ServiceClientTracing . Enter ( _invocationId , this , "ListKubernetesVersions" , tracingParameters ) ;
346
+ }
347
+ // Construct URL
348
+ var _baseUrl = Client . BaseUri . AbsoluteUri ;
349
+ var _url = new System . Uri ( new System . Uri ( _baseUrl + ( _baseUrl . EndsWith ( "/" ) ? "" : "/" ) ) , "subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/locations/{location}/kubernetesVersions" ) . ToString ( ) ;
350
+ _url = _url . Replace ( "{subscriptionId}" , System . Uri . EscapeDataString ( Client . SubscriptionId ) ) ;
351
+ _url = _url . Replace ( "{location}" , System . Uri . EscapeDataString ( location ) ) ;
352
+ List < string > _queryParameters = new List < string > ( ) ;
353
+ if ( Client . ApiVersion != null )
354
+ {
355
+ _queryParameters . Add ( string . Format ( "api-version={0}" , System . Uri . EscapeDataString ( Client . ApiVersion ) ) ) ;
356
+ }
357
+ if ( _queryParameters . Count > 0 )
358
+ {
359
+ _url += ( _url . Contains ( "?" ) ? "&" : "?" ) + string . Join ( "&" , _queryParameters ) ;
360
+ }
361
+ // Create HTTP transport objects
362
+ var _httpRequest = new HttpRequestMessage ( ) ;
363
+ HttpResponseMessage _httpResponse = null ;
364
+ _httpRequest . Method = new HttpMethod ( "GET" ) ;
365
+ _httpRequest . RequestUri = new System . Uri ( _url ) ;
366
+ // Set Headers
367
+ if ( Client . GenerateClientRequestId != null && Client . GenerateClientRequestId . Value )
368
+ {
369
+ _httpRequest . Headers . TryAddWithoutValidation ( "x-ms-client-request-id" , System . Guid . NewGuid ( ) . ToString ( ) ) ;
370
+ }
371
+ if ( Client . AcceptLanguage != null )
372
+ {
373
+ if ( _httpRequest . Headers . Contains ( "accept-language" ) )
374
+ {
375
+ _httpRequest . Headers . Remove ( "accept-language" ) ;
376
+ }
377
+ _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , Client . AcceptLanguage ) ;
378
+ }
379
+
380
+
381
+ if ( customHeaders != null )
382
+ {
383
+ foreach ( var _header in customHeaders )
384
+ {
385
+ if ( _httpRequest . Headers . Contains ( _header . Key ) )
386
+ {
387
+ _httpRequest . Headers . Remove ( _header . Key ) ;
388
+ }
389
+ _httpRequest . Headers . TryAddWithoutValidation ( _header . Key , _header . Value ) ;
390
+ }
391
+ }
392
+
393
+ // Serialize Request
394
+ string _requestContent = null ;
395
+ // Set Credentials
396
+ if ( Client . Credentials != null )
397
+ {
398
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
399
+ await Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
400
+ }
401
+ // Send Request
402
+ if ( _shouldTrace )
403
+ {
404
+ ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
405
+ }
406
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
407
+ _httpResponse = await Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
408
+ if ( _shouldTrace )
409
+ {
410
+ ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
411
+ }
412
+ HttpStatusCode _statusCode = _httpResponse . StatusCode ;
413
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
414
+ string _responseContent = null ;
415
+ if ( ( int ) _statusCode != 200 )
416
+ {
417
+ var ex = new CloudException ( string . Format ( "Operation returned an invalid status code '{0}'" , _statusCode ) ) ;
418
+ try
419
+ {
420
+ _responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
421
+ CloudError _errorBody = Rest . Serialization . SafeJsonConvert . DeserializeObject < CloudError > ( _responseContent , Client . DeserializationSettings ) ;
422
+ if ( _errorBody != null )
423
+ {
424
+ ex = new CloudException ( _errorBody . Message ) ;
425
+ ex . Body = _errorBody ;
426
+ }
427
+ }
428
+ catch ( JsonException )
429
+ {
430
+ // Ignore the exception
431
+ }
432
+ ex . Request = new HttpRequestMessageWrapper ( _httpRequest , _requestContent ) ;
433
+ ex . Response = new HttpResponseMessageWrapper ( _httpResponse , _responseContent ) ;
434
+ if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
435
+ {
436
+ ex . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
437
+ }
438
+ if ( _shouldTrace )
439
+ {
440
+ ServiceClientTracing . Error ( _invocationId , ex ) ;
441
+ }
442
+ _httpRequest . Dispose ( ) ;
443
+ if ( _httpResponse != null )
444
+ {
445
+ _httpResponse . Dispose ( ) ;
446
+ }
447
+ throw ex ;
448
+ }
449
+ // Create Result
450
+ var _result = new AzureOperationResponse < KubernetesVersionListResult > ( ) ;
451
+ _result . Request = _httpRequest ;
452
+ _result . Response = _httpResponse ;
453
+ if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
454
+ {
455
+ _result . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
456
+ }
457
+ // Deserialize Response
458
+ if ( ( int ) _statusCode == 200 )
459
+ {
460
+ _responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
461
+ try
462
+ {
463
+ _result . Body = Rest . Serialization . SafeJsonConvert . DeserializeObject < KubernetesVersionListResult > ( _responseContent , Client . DeserializationSettings ) ;
464
+ }
465
+ catch ( JsonException ex )
466
+ {
467
+ _httpRequest . Dispose ( ) ;
468
+ if ( _httpResponse != null )
469
+ {
470
+ _httpResponse . Dispose ( ) ;
471
+ }
472
+ throw new SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
473
+ }
474
+ }
475
+ if ( _shouldTrace )
476
+ {
477
+ ServiceClientTracing . Exit ( _invocationId , _result ) ;
478
+ }
479
+ return _result ;
480
+ }
481
+
269
482
/// <summary>
270
483
/// Gets a list of managed clusters in the specified subscription.
271
484
/// </summary>
0 commit comments