Model/POSTAccessDomainsSyncRB.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 DryRun
No description available.
.PARAMETER Scope
No description available.
.PARAMETER Full
No description available.
.PARAMETER Purge
No description available.
.PARAMETER Realm
No description available.
.PARAMETER RemoveVanished
No description available.
.PARAMETER EnableNew
No description available.
.OUTPUTS

POSTAccessDomainsSyncRB<PSCustomObject>
#>


function Initialize-PVEPOSTAccessDomainsSyncRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${DryRun},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("users", "groups", "both")]
        [String]
        ${Scope},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Full},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Purge},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Realm},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidatePattern("(?:(?:(?:acl|properties|entry);)*(?:acl|properties|entry))|none")]
        [String]
        ${RemoveVanished},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${EnableNew}
    )

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

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

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

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

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

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

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

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

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

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


         $DisplayNameMapping =@{
            "DryRun"="dry-run"; "Scope"="scope"; "Full"="full"; "Purge"="purge"; "Realm"="realm"; "RemoveVanished"="remove-vanished"; "EnableNew"="enable-new"
        }
        
         $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 POSTAccessDomainsSyncRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to POSTAccessDomainsSyncRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

POSTAccessDomainsSyncRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPOSTAccessDomainsSyncRB
        $AllProperties = ("dry-run", "scope", "full", "purge", "realm", "remove-vanished", "enable-new")
        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 "dry-run"))) { #optional property not found
            $DryRun = $null
        } else {
            $DryRun = $JsonParameters.PSobject.Properties["dry-run"].value
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "dry-run" = ${DryRun}
            "scope" = ${Scope}
            "full" = ${Full}
            "purge" = ${Purge}
            "realm" = ${Realm}
            "remove-vanished" = ${RemoveVanished}
            "enable-new" = ${EnableNew}
        }

        return $PSO
    }

}