* gen v1.23.0 * fix converter * bump ver * update readme runtime * fix warning * update dep ver * newtonjson -> system.text.json * generate for new json api * readme lf * dotnet fmt * dotnet fmt tests/ * dotnet fmt * Revert "dotnet fmt" This reverts commit e14c59076143fe2218ed899295a00762f0ea2bd6. * fix err introduce by dotnet fmt * fix test * remove deprecated /watch api * generate code after /watch removed * remove /watch related code * trim Microsoft.Rest.Serialization
104 lines
4.5 KiB
Plaintext
104 lines
4.5 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 Microsoft.Rest;
|
|
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 : ServiceClient<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 _baseUrl = BaseUri.AbsoluteUri;
|
|
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{{path}}").ToString();
|
|
{{#operation.parameters}}
|
|
{{#IfKindIs . "path"}}
|
|
_url = _url.Replace("{{AddCurly name}}", {{GetDotNetName name}});
|
|
{{/IfKindIs . "path"}}
|
|
{{/operation.parameters}}
|
|
_url = _url.Replace("/apis//", "/api/");
|
|
List<string> _queryParameters = new List<string>();
|
|
{{#operation.parameters}}
|
|
{{#IfKindIs . "query"}}
|
|
if ({{GetDotNetName name}} != null)
|
|
{
|
|
_queryParameters.Add(string.Format("{{name}}={0}", {{EscapeDataString name type}}));
|
|
}
|
|
{{/IfKindIs . "query"}}
|
|
{{/operation.parameters}}
|
|
if (_queryParameters.Count > 0)
|
|
{
|
|
_url += "?" + string.Join("&", _queryParameters);
|
|
}
|
|
// 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;
|
|
}
|
|
{{/.}}
|
|
}
|
|
}
|