Model/POSTAccessTicketRB.ps1

#
# Proxmox VE
# Generated module to access all Proxmox VE Api Endpoints
# Version: 0.3
# Contact: amna.wolf@gmail.com
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Password
No description available.
.PARAMETER NewFormat
No description available.
.PARAMETER Privs
No description available.
.PARAMETER Username
No description available.
.PARAMETER Path
No description available.
.PARAMETER Otp
No description available.
.PARAMETER TfaChallenge
No description available.
.PARAMETER Realm
No description available.
.OUTPUTS

POSTAccessTicketRB<PSCustomObject>
#>


function Initialize-PVEPOSTAccessTicketRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Password},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${NewFormat},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Privs},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Username},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Path},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Otp},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TfaChallenge},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Realm}
    )

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

        if ($NewFormat -and $NewFormat -gt 1) {
          throw "invalid value for 'NewFormat', must be smaller than or equal to 1."
        }

        if ($NewFormat -and $NewFormat -lt 0) {
          throw "invalid value for 'NewFormat', must be greater than or equal to 0."
        }

        if (!$Privs -and $Privs.length -gt 64) {
            throw "invalid value for 'Privs', the character length must be smaller than or equal to 64."
        }

        if (!$Username -and $Username.length -gt 64) {
            throw "invalid value for 'Username', the character length must be smaller than or equal to 64."
        }

        if (!$Path -and $Path.length -gt 64) {
            throw "invalid value for 'Path', the character length must be smaller than or equal to 64."
        }

        if (!$Realm -and $Realm.length -gt 32) {
            throw "invalid value for 'Realm', the character length must be smaller than or equal to 32."
        }


         $DisplayNameMapping =@{
            "Password"="password"; "NewFormat"="new-format"; "Privs"="privs"; "Username"="username"; "Path"="path"; "Otp"="otp"; "TfaChallenge"="tfa-challenge"; "Realm"="realm"
        }
        
         $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 POSTAccessTicketRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to POSTAccessTicketRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

POSTAccessTicketRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPOSTAccessTicketRB
        $AllProperties = ("password", "new-format", "privs", "username", "path", "otp", "tfa-challenge", "realm")
        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 "password"))) { #optional property not found
            $Password = $null
        } else {
            $Password = $JsonParameters.PSobject.Properties["password"].value
        }

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "privs"))) { #optional property not found
            $Privs = $null
        } else {
            $Privs = $JsonParameters.PSobject.Properties["privs"].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 "path"))) { #optional property not found
            $Path = $null
        } else {
            $Path = $JsonParameters.PSobject.Properties["path"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "password" = ${Password}
            "new-format" = ${NewFormat}
            "privs" = ${Privs}
            "username" = ${Username}
            "path" = ${Path}
            "otp" = ${Otp}
            "tfa-challenge" = ${TfaChallenge}
            "realm" = ${Realm}
        }

        return $PSO
    }

}