Model/PUTAccessUsersRB.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 Email
No description available.
.PARAMETER Comment
No description available.
.PARAMETER Append
No description available.
.PARAMETER Lastname
No description available.
.PARAMETER Firstname
No description available.
.PARAMETER Keys
No description available.
.PARAMETER Expire
No description available.
.PARAMETER Groups
No description available.
.PARAMETER Enable
No description available.
.PARAMETER Userid
No description available.
.OUTPUTS

PUTAccessUsersRB<PSCustomObject>
#>


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

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

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

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

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

        if ($Append -and $Append -lt 0) {
          throw "invalid value for 'Append', 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 ($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 (!$Userid -and $Userid.length -gt 64) {
            throw "invalid value for 'Userid', the character length must be smaller than or equal to 64."
        }


         $DisplayNameMapping =@{
            "Email"="email"; "Comment"="comment"; "Append"="append"; "Lastname"="lastname"; "Firstname"="firstname"; "Keys"="keys"; "Expire"="expire"; "Groups"="groups"; "Enable"="enable"; "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 PUTAccessUsersRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to PUTAccessUsersRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

PUTAccessUsersRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPUTAccessUsersRB
        $AllProperties = ("email", "comment", "append", "lastname", "firstname", "keys", "expire", "groups", "enable", "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 "email"))) { #optional property not found
            $Email = $null
        } else {
            $Email = $JsonParameters.PSobject.Properties["email"].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 "append"))) { #optional property not found
            $Append = $null
        } else {
            $Append = $JsonParameters.PSobject.Properties["append"].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 "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 "groups"))) { #optional property not found
            $Groups = $null
        } else {
            $Groups = $JsonParameters.PSobject.Properties["groups"].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 "userid"))) { #optional property not found
            $Userid = $null
        } else {
            $Userid = $JsonParameters.PSobject.Properties["userid"].value
        }

        $PSO = [PSCustomObject]@{
            "email" = ${Email}
            "comment" = ${Comment}
            "append" = ${Append}
            "lastname" = ${Lastname}
            "firstname" = ${Firstname}
            "keys" = ${Keys}
            "expire" = ${Expire}
            "groups" = ${Groups}
            "enable" = ${Enable}
            "userid" = ${Userid}
        }

        return $PSO
    }

}