Files
csharp/gen/LibKubernetesGenerator/templates/Kubernetes.cs.template
Boshi Lian 0d719f1fc6 7.1 remove old autorest (#785)
* init removal

* clean up warning

* bump ver to 7.1

* fix build

* custom http client no long supported

* cleanup unused types

* fix npe

* remove service client

* modern ssl settings

* fix test

* fix client cert null

* fix ctor

* cleanup
2022-02-25 13:33:23 -08:00

95 lines
4.0 KiB
Plaintext

// <auto-generated>
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/gen/KubernetesGenerator
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
namespace k8s
{
using k8s.Autorest;
using Models;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
public partial class Kubernetes : IKubernetes
{
{{#.}}
/// <inheritdoc/>
public async Task<HttpOperationResponse{{GetReturnType operation "<>"}}> {{GetMethodName operation "WithHttpMessagesAsync"}}(
{{#operation.parameters}}
{{GetDotNetType .}} {{GetDotNetName . "true"}},
{{/operation.parameters}}
IDictionary<string, IList<string>> customHeaders = null,
CancellationToken cancellationToken = default(CancellationToken))
{
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
cts.CancelAfter(HttpClientTimeout);
{{#IfParamContains operation "watch"}}
if (watch == true)
{
cts.CancelAfter(Timeout.InfiniteTimeSpan);
}
{{/IfParamContains operation "watch"}}
cancellationToken = cts.Token;
{{#operation.parameters}}
{{#isRequired}}
if ({{GetDotNetName name}} == null)
{
throw new ArgumentNullException("{{GetDotNetName name}}");
}
{{/isRequired}}
{{/operation.parameters}}
// Construct URL
var url = new System.Uri(BaseUri, $"{{ToInterpolationPathString path}}").ToString();
{{#IfGroupPathParamContainsGroup path}}
url = url.Replace("/apis//", "/api/");
{{/IfGroupPathParamContainsGroup}}
var q = new QueryBuilder();
{{#operation.parameters}}
{{#IfKindIs . "query"}}
q.Append("{{name}}", {{GetDotNetName name}});
{{/IfKindIs . "query"}}
{{/operation.parameters}}
url += q.ToString();
// Create HTTP transport
var httpRequest = CreateRequest(url, HttpMethod.{{Method}}, customHeaders);
{{#IfParamContains operation "body"}}
var httpResponse = await SendRequest(body, httpRequest, cancellationToken);
{{/IfParamContains operation "body"}}
{{#IfParamDoesNotContain operation "body"}}
var httpResponse = await SendRequestRaw("", httpRequest, cancellationToken);
{{/IfParamDoesNotContain operation "body"}}
// Create Result
{{#IfReturnType operation "void"}}
HttpOperationResponse result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse };
{{/IfReturnType operation "void"}}
{{#IfReturnType operation "obj"}}
var result = await CreateResultAsync{{GetReturnType operation "<>"}}(httpRequest,
httpResponse,
{{#IfParamContains operation "watch"}}
watch,
{{/IfParamContains operation "watch"}}
{{#IfParamDoesNotContain operation "watch"}}
false,
{{/IfParamDoesNotContain operation "watch"}}
cancellationToken);
{{/IfReturnType operation "obj"}}
{{#IfReturnType operation "stream"}}
var result = new HttpOperationResponse{{GetReturnType operation "<>"}}() {
Request = httpRequest,
Response = httpResponse,
Body = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false) };
{{/IfReturnType operation "stream"}}
return result;
}
{{/.}}
}
}