Inline tweak handler (#706)

* move tweak handler to template

* generated code

* remove handler from api
This commit is contained in:
Boshi Lian
2021-09-17 08:23:01 -07:00
committed by GitHub
parent 07ab21bb98
commit 6eea70326d
3 changed files with 747 additions and 19 deletions

View File

@@ -343,6 +343,7 @@ namespace k8s
// Construct URL
var _baseUrl = BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{{path}}").ToString();
_url = _url.Replace("/apis//", "/api/");
{{#operation.parameters}}
{{#IfKindIs . "path"}}
_url = _url.Replace("{{AddCurly name}}", {{GetDotNetName name}});

View File

@@ -9,35 +9,28 @@ namespace k8s
{
public class GenericClient : IDisposable
{
internal class TweakApiHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage msg, CancellationToken cancel)
{
msg.RequestUri = new Uri(msg.RequestUri, msg.RequestUri.AbsolutePath.Replace("/apis//", "/api/"));
return base.SendAsync(msg, cancel);
}
}
private readonly IKubernetes kubernetes;
private readonly string group;
private readonly string version;
private readonly string plural;
[Obsolete]
public GenericClient(KubernetesClientConfiguration config, string group, string version, string plural)
: this(new Kubernetes(config), group, version, plural)
{
}
public GenericClient(IKubernetes kubernetes, string version, string plural)
: this(kubernetes, "", version, plural)
{
}
public GenericClient(IKubernetes kubernetes, string group, string version, string plural)
{
this.group = group;
this.version = version;
this.plural = plural;
if (string.IsNullOrEmpty(group))
{
this.kubernetes = new Kubernetes(config, new DelegatingHandler[] { new TweakApiHandler() });
}
else
{
this.kubernetes = new Kubernetes(config);
}
this.kubernetes = kubernetes;
}
public async Task<T> ListAsync<T>(CancellationToken cancel = default(CancellationToken))

File diff suppressed because it is too large Load Diff