Api/AuthApi.ps1

#
# Cloud Governance Api
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# Version: 1.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

get delegate access token by client id and client secret which created in cloud governance Api Authentication Management

.DESCRIPTION

No description available.

.PARAMETER ClientSecret
No description available.

.PARAMETER UserPrincipalName
No description available.

.OUTPUTS

DelegatedAccessTokenApiResult
#>

function Get-DelegateAccessToken {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${ClientSecret},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${UserPrincipalName}
    )

    Process {
        'Calling method: Get-DelegateAccessToken' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

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

        $Configuration = Get-Configuration
        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('text/plain', 'application/json', 'text/json')

        $LocalVarUri = '/auth/token/delegate'

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientId"]) {
            $LocalVarHeaderParameters['ClientId'] = $Configuration["ApiKey"]["ClientId"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientSecret"]) {
            $LocalVarHeaderParameters['ClientSecret'] = $Configuration["ApiKey"]["ClientSecret"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["UserPrincipalName"]) {
            $LocalVarHeaderParameters['UserPrincipalName'] = $Configuration["ApiKey"]["UserPrincipalName"]
        }

        $LocalVarResult = Invoke-ApiClient -Method 'POST' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "DelegatedAccessTokenApiResult"

        return $LocalVarResult["Response"]
    }
}

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.OUTPUTS

None
#>

function Get-TokenUsage {
    [CmdletBinding()]
    Param (
    )

    Process {
        'Calling method: Get-TokenUsage' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

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

        $Configuration = Get-Configuration
        $LocalVarUri = '/auth/token/usage'

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientId"]) {
            $LocalVarHeaderParameters['ClientId'] = $Configuration["ApiKey"]["ClientId"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientSecret"]) {
            $LocalVarHeaderParameters['ClientSecret'] = $Configuration["ApiKey"]["ClientSecret"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["UserPrincipalName"]) {
            $LocalVarHeaderParameters['UserPrincipalName'] = $Configuration["ApiKey"]["UserPrincipalName"]
        }

        $LocalVarResult = Invoke-ApiClient -Method 'GET' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType ""

        return $LocalVarResult["Response"]
    }
}

<#
.SYNOPSIS

get the url which used to get user access token

.DESCRIPTION

No description available.

.PARAMETER RedirectUri
your application url to receive the token

.OUTPUTS

String
#>

function Get-UserTokenUrl {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${RedirectUri}
    )

    Process {
        'Calling method: Get-UserTokenUrl' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

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

        $Configuration = Get-Configuration
        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('text/plain', 'application/json', 'text/json')

        $LocalVarUri = '/auth/token/user/url'

        $LocalVarQueryParameters['redirect_uri'] = $RedirectUri

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientId"]) {
            $LocalVarHeaderParameters['ClientId'] = $Configuration["ApiKey"]["ClientId"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientSecret"]) {
            $LocalVarHeaderParameters['ClientSecret'] = $Configuration["ApiKey"]["ClientSecret"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["UserPrincipalName"]) {
            $LocalVarHeaderParameters['UserPrincipalName'] = $Configuration["ApiKey"]["UserPrincipalName"]
        }

        $LocalVarResult = Invoke-ApiClient -Method 'GET' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "String"

        return $LocalVarResult["Response"]
    }
}

<#
.SYNOPSIS

refresh user access token

.DESCRIPTION

No description available.

.PARAMETER RefreshToken
No description available.

.OUTPUTS

DelegatedAccessTokenApiResult
#>

function Invoke-RefreshUserAccessToken {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${RefreshToken}
    )

    Process {
        'Calling method: Invoke-RefreshUserAccessToken' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

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

        $Configuration = Get-Configuration
        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('text/plain', 'application/json', 'text/json')

        $LocalVarUri = '/auth/token/user/refresh'

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientId"]) {
            $LocalVarHeaderParameters['ClientId'] = $Configuration["ApiKey"]["ClientId"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["ClientSecret"]) {
            $LocalVarHeaderParameters['ClientSecret'] = $Configuration["ApiKey"]["ClientSecret"]
        }

        if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["UserPrincipalName"]) {
            $LocalVarHeaderParameters['UserPrincipalName'] = $Configuration["ApiKey"]["UserPrincipalName"]
        }

        $LocalVarResult = Invoke-ApiClient -Method 'POST' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "DelegatedAccessTokenApiResult"

        return $LocalVarResult["Response"]
    }
}