// // 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. // 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 { {{#.}} /// public async Task"}}> {{GetMethodName operation "WithHttpMessagesAsync"}}( {{#operation.parameters}} {{GetDotNetType .}} {{GetDotNetName . "true"}}, {{/operation.parameters}} IDictionary> 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; } {{/.}} } }