Model/POSTNodesQemuFirewallIpsetRB.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 Cidr
No description available.
.PARAMETER Comment
No description available.
.PARAMETER Node
No description available.
.PARAMETER Name
No description available.
.PARAMETER Vmid
No description available.
.PARAMETER Nomatch
No description available.
.OUTPUTS

POSTNodesQemuFirewallIpsetRB<PSCustomObject>
#>


function Initialize-PVEPOSTNodesQemuFirewallIpsetRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Cidr},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Comment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Node},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidatePattern("[A-Za-z][A-Za-z0-9\-\_]+")]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Vmid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Nomatch}
    )

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

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

        if (!$Name -and $Name.length -lt 2) {
            throw "invalid value for 'Name', the character length must be great than or equal to 2."
        }

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

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

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

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


         $DisplayNameMapping =@{
            "Cidr"="cidr"; "Comment"="comment"; "Node"="node"; "Name"="name"; "Vmid"="vmid"; "Nomatch"="nomatch"
        }
        
         $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 POSTNodesQemuFirewallIpsetRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to POSTNodesQemuFirewallIpsetRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

POSTNodesQemuFirewallIpsetRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPOSTNodesQemuFirewallIpsetRB
        $AllProperties = ("cidr", "comment", "node", "name", "vmid", "nomatch")
        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 "cidr"))) { #optional property not found
            $Cidr = $null
        } else {
            $Cidr = $JsonParameters.PSobject.Properties["cidr"].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 "node"))) { #optional property not found
            $Node = $null
        } else {
            $Node = $JsonParameters.PSobject.Properties["node"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "cidr" = ${Cidr}
            "comment" = ${Comment}
            "node" = ${Node}
            "name" = ${Name}
            "vmid" = ${Vmid}
            "nomatch" = ${Nomatch}
        }

        return $PSO
    }

}