Model/AccessTicket.ps1

#
# Proxmox PowerShell VE
# Generated module to access all Proxmox VE Api Endpoints. This module has been generated from the proxmox api description v. 8.4.0
# Version: 8.4.0
# Contact: mail@timo-wolf.de
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Ticket
No description available.
.PARAMETER Username
No description available.
.PARAMETER Clustername
No description available.
.PARAMETER CSRFPreventionToken
No description available.
.OUTPUTS

AccessTicket<PSCustomObject>
#>


function Initialize-PVEAccessTicket {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Ticket},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Username},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Clustername},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CSRFPreventionToken}
    )

    Process {
        'Creating PSCustomObject: ProxmoxPVE => PVEAccessTicket' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug


         $DisplayNameMapping =@{
            "Ticket"="ticket"; "Username"="username"; "Clustername"="clustername"; "CSRFPreventionToken"="CSRFPreventionToken"
        }
        
         $OBJ = @{}
        foreach($parameter in   $PSBoundParameters.Keys){
            #If Specifield map the Display name back
            $OBJ.($DisplayNameMapping.($parameter)) = $PSBoundParameters.$parameter
        }

        $PSO = [PSCustomObject]$OBJ


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to AccessTicket<PSCustomObject>

.DESCRIPTION

Convert from JSON to AccessTicket<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AccessTicket<PSCustomObject>
#>

function ConvertFrom-PVEJsonToAccessTicket {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: ProxmoxPVE => PVEAccessTicket' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEAccessTicket
        $AllProperties = ("ticket", "username", "clustername", "CSRFPreventionToken")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "ticket"))) { #optional property not found
            $Ticket = $null
        } else {
            $Ticket = $JsonParameters.PSobject.Properties["ticket"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "username"))) { #optional property not found
            $Username = $null
        } else {
            $Username = $JsonParameters.PSobject.Properties["username"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "clustername"))) { #optional property not found
            $Clustername = $null
        } else {
            $Clustername = $JsonParameters.PSobject.Properties["clustername"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "CSRFPreventionToken"))) { #optional property not found
            $CSRFPreventionToken = $null
        } else {
            $CSRFPreventionToken = $JsonParameters.PSobject.Properties["CSRFPreventionToken"].value
        }

        $PSO = [PSCustomObject]@{
            "ticket" = ${Ticket}
            "username" = ${Username}
            "clustername" = ${Clustername}
            "CSRFPreventionToken" = ${CSRFPreventionToken}
        }

        return $PSO
    }

}