All Downloads are FREE. Search and download functionalities are using the official Maven repository.

powershell.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
{{> partial_header}}
{{#operations}}
{{#operation}}
<#
.SYNOPSIS

{{{summary}}}{{^summary}}No summary available.{{/summary}}

.DESCRIPTION

{{{description}}}{{^description}}No description available.{{/description}}

{{#allParams}}
.PARAMETER {{{paramName}}}
{{{description}}}{{^description}}No description available.{{/description}}

{{/allParams}}
{{#vendorExtensions.x-powershell-select-accept}}
.PARAMETER ReturnType

Select the return type (optional): {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}

{{/vendorExtensions.x-powershell-select-accept}}
.PARAMETER WithHttpInfo

A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response

.OUTPUTS

{{{returnType}}}{{^returnType}}None{{/returnType}}
#>
function {{{vendorExtensions.x-powershell-method-name}}} {
    [CmdletBinding()]
    Param (
    {{#allParams}}
        [Parameter(Position = {{vendorExtensions.x-index}}{{#-first}}, ValueFromPipeline = $true{{/-first}}, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        {{#isEnum}}
        {{#allowableValues}}
        [ValidateSet({{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}})]
        {{/allowableValues}}
        {{/isEnum}}
        [{{{vendorExtensions.x-powershell-data-type}}}]
        {{=<% %>=}}
        ${<%paramName%>},
        <%={{ }}=%>
    {{/allParams}}
        {{#vendorExtensions.x-powershell-select-accept}}
        [String]
        [ValidateSet({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}})]
        $ReturnType,
        {{/vendorExtensions.x-powershell-select-accept}}
        [Switch]
        $WithHttpInfo
    )

    Process {
        'Calling method: {{{vendorExtensions.x-powershell-method-name}}}' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $LocalVarAccepts = @()
        $LocalVarContentTypes = @()
        $LocalVarQueryParameters = @{}
        $LocalVarHeaderParameters = @{}
        $LocalVarFormParameters = @{}
        $LocalVarPathParameters = @{}
        $LocalVarCookieParameters = @{}
        $LocalVarBodyParameter = $null

        $Configuration = Get-{{{apiNamePrefix}}}Configuration
        {{#hasProduces}}
        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @({{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}})

        {{/hasProduces}}
        {{#vendorExtensions.x-powershell-select-accept}}
        if ($ReturnType) {
            # use the return type (MIME) provided by the user
            $LocalVarAccepts = @($ReturnType)
        }

        {{/vendorExtensions.x-powershell-select-accept}}
        {{#hasConsumes}}
        # HTTP header 'Content-Type'
        $LocalVarContentTypes = @({{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}})

        {{/hasConsumes}}
        $LocalVarUri = '{{{path}}}'
        {{=< >=}}
        <#pathParams>
        if (!$) {
            throw "Error! The required parameter `` missing when calling ."
        }
        $LocalVarUri = $LocalVarUri.replace('{}', [System.Web.HTTPUtility]::UrlEncode($))
        
        <={{ }}=>

        {{#headerParams}}
        {{#required}}
        {{^isNullable}}
        if (!${{{paramName}}}) {
            throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
        }
        $LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{^required}}
        {{^isNullable}}
        if (${{{paramName}}}) {
            $LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
        }

        {{/isNullable}}
        {{#isNullable}}
        $LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{/headerParams}}
        {{#queryParams}}
        {{#required}}
        {{^isNullable}}
        if (!${{{paramName}}}) {
            throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
        }
        $LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{^required}}
        {{^isNullable}}
        if (${{{paramName}}}) {
            $LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
        }

        {{/isNullable}}
        {{#isNullable}}
        $LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{/queryParams}}
        {{#formParams}}
        {{#required}}
        {{^isNullable}}
        if (!${{{paramName}}}) {
            throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
        }
        $LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{^required}}
        {{^isNullable}}
        if (${{{paramName}}}) {
            $LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
        }

        {{/isNullable}}
        {{#isNullable}}
        $LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}

        {{/isNullable}}
        {{/required}}
        {{/formParams}}
        {{#bodyParam}}
        {{#required}}
        {{^isNullable}}
        if (!${{{paramName}}}) {
            throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
        }

        {{/isNullable}}
        {{/required}}
        $LocalVarBodyParameter = ${{{paramName}}} | ConvertTo-Json -Depth 100

        {{/bodyParam}}
        {{#authMethods}}
        {{#isApiKey}}
        {{#isKeyInHeader}}
        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) {
            $LocalVarHeaderParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"]
            Write-Verbose ("Using API key '{{{keyParamName}}}' in the header for authentication in {0}" -f $MyInvocation.MyCommand)
        }
        {{/isKeyInHeader}}
        {{#isKeyInQuery}}
        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) {
            $LocalVarQueryParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"]
            Write-Verbose ("Using API key `{{{keyParamName}}}` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand)
        }
        {{/isKeyInQuery}}
        {{#isKeyInCookie}}
        if ($Configuration["Cookie"]) {
            $LocalVarCookieParameters['{{{name}}}'] = $Configuration["Cookie"]
            Write-Verbose ("Using API key `{{{name}}}` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand)
        }
        {{/isKeyInCookie}}
        {{/isApiKey}}
        {{#isBasicBasic}}
        if ($Configuration["Username"] -and $Configuration["Password"]) {
            $LocalVarBytes = [System.Text.Encoding]::UTF8.GetBytes($Configuration["Username"] + ":" + $Configuration["Password"])
            $LocalVarBase64Text =[Convert]::ToBase64String($LocalVarBytes)
            $LocalVarHeaderParameters['Authorization'] = "Basic " + $LocalVarBase64Text
            Write-Verbose ("Using HTTP basic authentication in {0}" -f $MyInvocation.MyCommand)
        }
        {{/isBasicBasic}}
        {{#isBasicBearer}}
        if ($Configuration["AccessToken"]) {
            $LocalVarHeaderParameters['Authorization'] = "Bearer " + $Configuration["AccessToken"]
            Write-Verbose ("Using Bearer authentication in {0}" -f $MyInvocation.MyCommand)
        }
        {{/isBasicBearer}}

        {{/authMethods}}
        $LocalVarResult = Invoke-{{{apiNamePrefix}}}ApiClient -Method '{{httpMethod}}' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "{{{returnType}}}" `
                                -IsBodyNullable {{#bodyParam}}{{#isNullable}}$true{{/isNullable}}{{^isNullable}}$false{{/isNullable}}{{/bodyParam}}{{^bodyParam}}$false{{/bodyParam}}

        {{#vendorExtensions.x-ps-return-type-one-of}}
        # process oneOf response
        $LocalVarResult["Response"] = ConvertFrom-{{apiNamePrefix}}JsonTo{{returnType}} (ConvertTo-Json $LocalVarResult["Response"] -Depth 100)

        {{/vendorExtensions.x-ps-return-type-one-of}}
        {{#vendorExtensions.x-ps-return-type-any-of}}
        # process anyOf response
        $LocalVarResult["Response"] = ConvertFrom-{{apiNamePrefix}}JsonTo{{returnType}} (ConvertTo-Json $LocalVarResult["Response"] -Depth 100)

        {{/vendorExtensions.x-ps-return-type-any-of}}
        if ($WithHttpInfo.IsPresent) {
            return $LocalVarResult
        } else {
            return $LocalVarResult["Response"]
        }
    }
}

{{/operation}}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy