Model/PUTAccessAclRB.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 Users
No description available.
.PARAMETER Propagate
No description available.
.PARAMETER Path
No description available.
.PARAMETER Delete
No description available.
.PARAMETER Roles
No description available.
.PARAMETER Groups
No description available.
.PARAMETER Tokens
No description available.
.OUTPUTS

PUTAccessAclRB<PSCustomObject>
#>


function Initialize-PVEPUTAccessAclRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Users},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Propagate},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Path},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Delete},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Roles},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Groups},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Tokens}
    )

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

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

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

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

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


         $DisplayNameMapping =@{
            "Users"="users"; "Propagate"="propagate"; "Path"="path"; "Delete"="delete"; "Roles"="roles"; "Groups"="groups"; "Tokens"="tokens"
        }
        
         $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 PUTAccessAclRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to PUTAccessAclRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

PUTAccessAclRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPUTAccessAclRB
        $AllProperties = ("users", "propagate", "path", "delete", "roles", "groups", "tokens")
        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 "users"))) { #optional property not found
            $Users = $null
        } else {
            $Users = $JsonParameters.PSobject.Properties["users"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "users" = ${Users}
            "propagate" = ${Propagate}
            "path" = ${Path}
            "delete" = ${Delete}
            "roles" = ${Roles}
            "groups" = ${Groups}
            "tokens" = ${Tokens}
        }

        return $PSO
    }

}