// <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>

namespace k8s;

/// <summary>
/// Extension methods for Kubernetes.
/// </summary>
public static partial class {{name}}OperationsExtensions
{
    {{for api in apis }}
    /// <summary>
    /// {{ToXmlDoc api.operation.description}}
    /// </summary>
    /// <param name='operations'>
    /// The operations group for this extension method.
    /// </param>
     {{ for parameter in api.operation.parameters}}
    /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
    /// {{ToXmlDoc api.description}}
    /// </param>
     {{ end }}
    public static {{GetReturnType api.operation "void"}} {{GetOperationId api.operation ""}}(
        this I{{name}}Operations operations
{{ for parameter in api.operation.parameters}}
        ,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}
{{end}}
        )
   {
         {{GetReturnType api.operation "return"}}  operations.{{GetOperationId api.operation "Async"}}(
{{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
{{end}}
             CancellationToken.None
        ).GetAwaiter().GetResult();
    }

    {{if IfReturnType api.operation "object"}}
    /// <summary>
    /// {{ToXmlDoc api.operation.description}}
    /// </summary>
    /// <param name='operations'>
    /// The operations group for this extension method.
    /// </param>
    {{ for parameter in api.operation.parameters}}
    /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
    /// {{ToXmlDoc parameter.description}}
    /// </param>
    {{end}}
    public static T {{GetOperationId api.operation ""}}<T>(
        this I{{name}}Operations operations
{{ for parameter in api.operation.parameters}}
        ,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}
{{end}}
        )
   {
         return operations.{{GetOperationId api.operation "Async"}}<T>(
{{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
{{end}}
             CancellationToken.None
        ).GetAwaiter().GetResult();
    }
    {{end}}

    /// <summary>
    /// {{ToXmlDoc api.operation.description}}
    /// </summary>
    /// <param name='operations'>
    /// The operations group for this extension method.
    /// </param>
    {{ 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 static async Task{{GetReturnType api.operation "<>"}} {{GetOperationId api.operation "Async"}}(
        this I{{name}}Operations operations,
{{ for parameter in api.operation.parameters}}
        {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
{{ end }}
        CancellationToken cancellationToken = default(CancellationToken))
    {
        {{if IfReturnType api.operation "stream"}}
        var _result = await operations.{{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 operations.{{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 operations.{{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>
    /// <param name='operations'>
    /// The operations group for this extension method.
    /// </param>
    {{ 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 static async Task<T> {{GetOperationId api.operation "Async"}}<T>(
        this I{{name}}Operations operations,
{{ for parameter in api.operation.parameters}}
        {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
{{ end }}
        CancellationToken cancellationToken = default(CancellationToken))
    {
        using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
{{ for parameter in api.operation.parameters}}
            {{GetDotNetNameOpenApiParameter parameter "false"}},
{{end}}
            null,
            cancellationToken).ConfigureAwait(false))
        {
            return _result.Body;
        }
    }
    {{end}}

    {{end}}
}
