// <auto-generated>
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using System.Net.Http;
using System.Net.Http.Headers;

namespace k8s.ClientSets;

/// <summary>
/// </summary>
public partial class {{name}}Client : ResourceClient
{
    public {{name}}Client(Kubernetes kubernetes) : base(kubernetes)
    {
    }

    {{for api in apis }}
    /// <summary>
    /// {{ToXmlDoc api.operation.description}}
    /// </summary>
    {{ for parameter in api.operation.parameters}}
    /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
    /// {{ToXmlDoc parameter.description}}
    /// </param>
    {{end}}
    /// <param name="cancellationToken">
    /// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
    /// </param>
    public async Task{{GetReturnType api.operation "<>"}} {{GetActionName api.operation name "Async"}}(
        {{ for parameter in api.operation.parameters}}
        {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
        {{ end }}
        CancellationToken cancellationToken = default(CancellationToken))
    {
        {{if IfReturnType api.operation "stream"}}
        var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
            {{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
            {{end}}
            null,
            cancellationToken);
        _result.Request.Dispose();
        {{GetReturnType api.operation "_result.Body"}};
        {{end}}
        {{if IfReturnType api.operation "obj"}}
        using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
            {{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
            {{end}}
            null,
            cancellationToken).ConfigureAwait(false))
        {
            {{GetReturnType api.operation "_result.Body"}};
        }
        {{end}}
        {{if IfReturnType api.operation "void"}}
        using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
            {{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
            {{end}}
            null,
            cancellationToken).ConfigureAwait(false))
        {
        }
        {{end}}
    }

    {{if IfReturnType api.operation "object"}}
    /// <summary>
    /// {{ToXmlDoc api.operation.description}}
    /// </summary>
    {{ for parameter in api.operation.parameters}}
    /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
    /// {{ToXmlDoc parameter.description}}
    /// </param>
    {{end}}
    /// <param name="cancellationToken">
    /// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
    /// </param>
    public async Task<T> {{GetActionName api.operation name "Async"}}<T>(
        {{ for parameter in api.operation.parameters}}
        {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
        {{ end }}
        CancellationToken cancellationToken = default(CancellationToken))
    {
        using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
            {{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
            {{end}}
            null,
            cancellationToken).ConfigureAwait(false))
        {
            return _result.Body;
        }
    }
    {{end}}
    {{end}}
}
