Model/AccessUsersGETInner.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 Tokens
No description available.
.PARAMETER RealmType
No description available.
.PARAMETER TfaLockedUntil
No description available.
.PARAMETER Comment
No description available.
.PARAMETER Keys
No description available.
.PARAMETER Expire
No description available.
.PARAMETER Enable
No description available.
.PARAMETER Email
No description available.
.PARAMETER TotpLocked
No description available.
.PARAMETER Lastname
No description available.
.PARAMETER Firstname
No description available.
.PARAMETER Groups
No description available.
.PARAMETER Userid
No description available.
.OUTPUTS

AccessUsersGETInner<PSCustomObject>
#>


function Initialize-PVEAccessUsersGETInner {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Tokens},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RealmType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${TfaLockedUntil},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Comment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidatePattern("[0-9a-zA-Z!=]{0,4096}")]
        [String]
        ${Keys},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Expire},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Enable},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Email},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${TotpLocked},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Lastname},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Firstname},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Groups},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Userid}
    )

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

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

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

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

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

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

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

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

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

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


         $DisplayNameMapping =@{
            "Tokens"="tokens"; "RealmType"="realm-type"; "TfaLockedUntil"="tfa-locked-until"; "Comment"="comment"; "Keys"="keys"; "Expire"="expire"; "Enable"="enable"; "Email"="email"; "TotpLocked"="totp-locked"; "Lastname"="lastname"; "Firstname"="firstname"; "Groups"="groups"; "Userid"="userid"
        }
        
         $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 AccessUsersGETInner<PSCustomObject>

.DESCRIPTION

Convert from JSON to AccessUsersGETInner<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AccessUsersGETInner<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEAccessUsersGETInner
        $AllProperties = ("tokens", "realm-type", "tfa-locked-until", "comment", "keys", "expire", "enable", "email", "totp-locked", "lastname", "firstname", "groups", "userid")
        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 "tokens"))) { #optional property not found
            $Tokens = $null
        } else {
            $Tokens = $JsonParameters.PSobject.Properties["tokens"].value
        }

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

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "tokens" = ${Tokens}
            "realm-type" = ${RealmType}
            "tfa-locked-until" = ${TfaLockedUntil}
            "comment" = ${Comment}
            "keys" = ${Keys}
            "expire" = ${Expire}
            "enable" = ${Enable}
            "email" = ${Email}
            "totp-locked" = ${TotpLocked}
            "lastname" = ${Lastname}
            "firstname" = ${Firstname}
            "groups" = ${Groups}
            "userid" = ${Userid}
        }

        return $PSO
    }

}